VB的数据读取
来源:百度知道 编辑:UC知道 时间:2024/05/22 08:51:41
如何用VB读取txt文件呢?
例如:我要读取E:\托盘.txt 然后在VB里的text1.text里显示
例如:我要读取E:\托盘.txt 然后在VB里的text1.text里显示
dim k,s
open "E:\托盘.txt" for input as #1
do while not eof(1)
line input #1 ,s
k = k & s & vbcrlf
loop
close #1
text1 = k
Dim nFileNum As Integer
Dim strFileName As String
Dim strLine As String
Dim strData As String
nFileNum = FreeFile()
strFileName = "E:\托盘.txt"
Open strFileName For Input As nFileNum
While Not EOF(nFileNum)
Line Input #nFileNum, strLine
strData = strData & strLine & vbCrLf
Wend
Close nFileNum
Text1.Text = strData