如何在TXT文件中读取数据并存入到VB数组中?

如题所述

如果TXT文件是单行的话
Open "c:\1.txt" For Binary As #1
Text1.Text = Input(lof(1), 1)
Close #1
Dim a
a = Split(Text1.Text)

如果是多行要加循环

Option Explicit
Dim a$, n%, k%, c$(), d%

Private Sub Form_Click()
n = 0
Open App.Path & "\temp.txt" For Input As #1
Do Until EOF(1)
n = n + 1
Line Input #1, a
ReDim c(n)
d = Len(a)
k = InStr(1, a, "=")
c(n) = Right(a, (d - k + 1))
Print "c(" & n & ")=" & c(n)
Loop
Close #1
End Sub
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答