vb 读取txt内容,并赋值给数组?
2个回答
展开全部
假如文本存在e:\1.txt
内容为:
001,张三
002,李四
003,王武
004,网吧但
Private Sub Command1_Click()
Dim a(1 To 100)
Dim b(1 To 100)
Dim str As String, i As Integer
i = 1
Open "e:\1.txt" For Input As #1
Do While Not EOF(1)
Input #1, str
a(i) = Left(str, 3)
b(i) = Right(str, Len(str) - 4)
'MsgBox a(i) & b(i)
i = i + 1
Loop
Close #1
End Sub
内容为:
001,张三
002,李四
003,王武
004,网吧但
Private Sub Command1_Click()
Dim a(1 To 100)
Dim b(1 To 100)
Dim str As String, i As Integer
i = 1
Open "e:\1.txt" For Input As #1
Do While Not EOF(1)
Input #1, str
a(i) = Left(str, 3)
b(i) = Right(str, Len(str) - 4)
'MsgBox a(i) & b(i)
i = i + 1
Loop
Close #1
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询