如何把txt文件中的多个数据,分别读取到多个text控件中显示出来?
txt文件中数据排列如:
AO
BO
C0
01
05
文本中每一行只有2个数字,
使用一个command控件,6个text控件,
要求点击一次command控件使txt文件中每一行的数字分别在6个text文本框中显示出来。
txt文件中数据排列如:
AO
BO
C0
01
05
文本中每一行只有2个数字,
使用一个command控件,6个text控件,
要求点击一次command控件使txt文件中每一行的数字分别在6个text文本框中显示出来。
fileNum = FreeFile
Open "文本文件.txt" For Input As #fileNum
i=0
While Not EOF(fileNum)
Line Input #fileNum, temp
j=i+1
Select Case i
Case 1:text1.text = temp
Case 2:text2.text = temp
Case 3:text3.text = temp
Case 4:text4.text = temp
Case 5:text5.text = temp
Case 6:text6.text = temp
End Select
i=(i+1) mod 7
Wend
Close #fileNum
Dim a$(1 To 6), i%, j%
Open "D:\1.txt" For Input As #1
i = 0
While Not EOF(1)
i = i + 1
Line Input #1, a(i)
Wend
For j = 1 To i
Text1(j - 1).Text = a(j)
Next
Close #1
End Sub
s = StrConv(InputB(LOF(1), #1), vbUnicode)
a = Split(s, vbCrLf)
For i = 1 To UBound(a) + 1
Me.Controls("Text" & i).Text = a(i - 1)
Next
Close #1
Dim fileNum As Integer,temp as string
fileNum = FreeFile
Open "文本文件.txt" For Input As #fileNum
i=0
While Not EOF(fileNum)
Line Input #fileNum, temp
j=i+1
Select Case j
Case 1:text1.text = temp
Case 2:text2.text = temp
Case 3:text3.text = temp
Case 4:text4.text = temp
Case 5:text5.text = temp
Case 6:text6.text = temp
End Select
i=(i+1) mod 7
Wend
Close #fileNum