VB怎么读取一个TXT文件然后赋值在变量上?

2024-12-12 06:15:59
推荐回答(2个)
回答1:

Dim str As String
Dim TEM As String
Open "C:\Documents and Settings\Administrator\桌面\1.TXT" For Input As 1
Do Until EOF(1)
Line Input #1, TEM
str = str + TEM
Loop
Close #1
其中line input是读取一行的数据,这个函数比较重要,以上代码以及运行过了,呵呵

回答2:

Dim str As String
Dim TEM As String
Open "C:\Documents and Settings\Administrator\桌面\1.TXT" For Input As 1
Do Until EOF(1)
Line Input #1, TEM
str = str + TEM
Loop
Close #1
其中line input是读取一行的数据,这个函数比较重要,以上代码以及运行过了。