txt的内容如下:
帐号-----姓名-----余额-----备注
00001-----9527ABC-----50.00-----ERR
0002-----fdffs-----42.5-----TRET
0025-----dsf5645-----95.23-----OIHJ
行数不定
分别读取 '-----' 不要
txt的内容如下:
帐号-----姓名-----余额-----备注
00001-----9527ABC-----50.00-----ERR
0002-----fdffs-----42.5-----TRET
0025-----dsf5645-----95.23-----OIHJ
行数不定
分别读取 '-----' 不要
Dim arrData(10, 3) As String
Dim tmpstr As String
Dim tmparr() As String
Dim i As Integer
i = 0
Open "c:\1.txt" For Input As #1
While Not EOF(1)
Line Input #1, tmpstr
If tmpstr <> "" Then
tmparr = Split(tmpstr, "-----")
arrData(i, 0) = tmparr(0)
arrData(i, 1) = tmparr(1)
arrData(i, 2) = tmparr(2)
arrData(i, 3) = tmparr(3)
i = i + 1
End If
Wend
Close #1
tmpstr = ""
For i = 0 To 2
tmpstr = tmpstr & arrData(i, 0) & " " & arrData(i, 1) & " " & arrData(i, 2) & " " & arrData(i, 3) & " " & vbCrLf
Next i
MsgBox tmpstr
控件你加载了吗?你看代码运行到哪一句出错了