![]() |
#2
lowxiong2013-02-15 11:30
|

Private Sub Command1_Click()
On Error GoTo Errhandler
'设置过滤器
CommonDialog1.Filter = "数据文档(*.txt)|*.txt"
CommonDialog1.Action = 1
Text1 = CommonDialog1.FileName
Errhandler:
Exit Sub
End Sub
Private Sub Command2_Click()
Dim s As String
ReDim f(m, n) As String
Dim a As String, b() As String, c() As String
Open Text1.Text For Input As #1
m = 0
Line Input #1, a
b = Split(a, " ")
For n = 0 To UBound(b)
f(m, n) = b(n) 这里出现下标越界
n = n + 1
Next n
m = m + 1
Line Input #1, a
s = Replace(a, vbTab, " ")
c = Split(s, " ")
For n = 0 To UBound(c)
' f(m, n) = b(n) 这里出现下标越界
n = n + 1
Next n
Close #1
Text2.Text = b(0)
Text3.Text = f(1, 1)
End Sub
总是提示下标越界,不懂啊 ,高手们教教 On Error GoTo Errhandler
'设置过滤器
CommonDialog1.Filter = "数据文档(*.txt)|*.txt"
CommonDialog1.Action = 1
Text1 = CommonDialog1.FileName
Errhandler:
Exit Sub
End Sub
Private Sub Command2_Click()
Dim s As String
ReDim f(m, n) As String
Dim a As String, b() As String, c() As String
Open Text1.Text For Input As #1
m = 0
Line Input #1, a
b = Split(a, " ")
For n = 0 To UBound(b)
f(m, n) = b(n) 这里出现下标越界
n = n + 1
Next n
m = m + 1
Line Input #1, a
s = Replace(a, vbTab, " ")
c = Split(s, " ")
For n = 0 To UBound(c)
' f(m, n) = b(n) 这里出现下标越界
n = n + 1
Next n
Close #1
Text2.Text = b(0)
Text3.Text = f(1, 1)
End Sub