标题:数组输出求助
只看楼主
菜鸟新上路
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2008-9-15
结帖率:60%
已结贴  问题点数:15 回复次数:3 
数组输出求助
原文本:
58724   2001   04   60,80,17,
58724   2001   04   60,80,17,
58724   2001   04   60,
58724   2001   04   80,60,
58724   2001   04   01,10,60,
58724   2001   04   60,10,
58724   2001   04   15,17,80,60,
代码:
Private Sub Command1_Click()
Dim s As String
Dim flag As Integer
flag = 0
myfile1 = App.Path & "\" & "天气日数4.txt"
myfile2 = App.Path & "\" & "天气日数8.txt"
Open myfile1 For Input As #1
Open myfile2 For Output As #2
'Print #2, ; Spc(2); "站名"; Spc(2); "年"; Spc(2); "月"; Spc(2); "风速"; Spc(2); "风向"
Do While Not EOF(1)
Line Input #1, s
Dim arr
While InStr(s, ";")
  s = Replace(s, ";", ",")
Wend
arr = Split(s, ",")
  For i = LBound(arr) To UBound(arr)
     Print #2, arr(i)
  Next i
'flag = flag + 1
Loop
Close #2
Close #1
End Sub
Private Sub Command2_Click()
代码得到的结果:
58724   2001   04   (60
80
17

58724   2001   04   (60
80
17

58724   2001   04   (60

58724   2001   04   (80
60

58724   2001   04   (01
而本人想要的结果:
58724   2001   04   60

58724   2001   04   80  60

58724   2001   04   01  10  60

58724   2001   04   60  10

58724   2001   04   15  17  80   60

58724   2001   04   01

58724   2001   04   80  17
请问如何修改代码中的红色部分,才能实现我想要的结果,给5-10分


搜索更多相关主题的帖子: 天气 
2011-01-24 16:15
Artless
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:4211
专家分:28888
注 册:2009-4-8
得分:8 
代码得不到这样的结果:
58724   2001   04   (60
80
17

58724   2001   04   (60
80
17

58724   2001   04   (60

58724   2001   04   (80
60

58724   2001   04   (01

无知
2011-01-24 16:29
菜鸟新上路
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2008-9-15
得分:0 
回复 2楼 Artless
请问如何才能得到我想要的结果
2011-01-24 17:26
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
得分:8 
Private Sub Command1_Click()
Dim s As String, myfile1$, myfile2$
Dim flag As Integer, i&
flag = 0
myfile1 = App.Path & "\" & "天气日数4.txt"
myfile2 = App.Path & "\" & "天气日数8.txt"
Open myfile1 For Input As #1
Open myfile2 For Output As #2
'Print #2, ; Spc(2); "站名"; Spc(2); "年"; Spc(2); "月"; Spc(2); "风速"; Spc(2); "风向"
Do While Not EOF(1)
Line Input #1, s
Dim arr
While InStr(s, ";")
  s = Replace(s, ";", ",")
Wend
arr = Split(s, ",")
For i = LBound(arr) To UBound(arr)
     Print #2, arr(i),
  Next i
  Print #2, ""
'flag = flag + 1
Loop
Close #2
Close #1
End Sub
2011-01-24 23:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-331509-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.372683 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved