有关下标越界的问题
文本一1 1 11 1
2 2 22 2
3 3 33 3
4 4 44 4
5 5 55 5
6 6 66 6
7 7 77 7
1 1 11 1
2 2 22 2
3 3 33 3
4 4 44 4
5 5 55 5
6 6 66 6
7 7 77
文本二
723:22:20 1 24.4
23:22:25 2 24.3
23:22:30 3 24.1
23:22:35 4 24.1
23:22:40 5 23.9
本人是每隔六行提取一行数据,且只提取第三个字符,[bo]我提取文本一时,程序正常运行,但是提取文本二时,显示下届超标[/bo],请问我应该如何修改?
程序语言如下:
Private Sub Command1_Click()
Dim s As String
Dim flag As Integer
flag = 0
myfile1 = App.Path & "\" & "2.txt"
myfile2 = App.Path & "\" & "4.txt"
Open myfile1 For Input As #1
Open myfile2 For Output As #2
Do While Not EOF(1)
Line Input #1, s
If flag Mod 6 = 0 Then
Dim arr
While InStr(s, " ")
s = Replace(s, " ", " ")
Wend
arr = Split(s, " ")
Print #2, arr(2)
End If
flag = flag + 1
Loop
Close #1
End Sub
[[it] 本帖最后由 菜鸟新上路 于 2008-9-17 13:32 编辑 [/it]]