VB怎么读TXT文件行数和列数!
咧如:102030112233778899TXT文件放在:E:\a.txt单击第一个命令按钮:第一行的全部放到Text1.text,Text2.text,Text3.te...
咧如:10 20 30 11 22 33 77 88 99 TXT文件放在:E:\a.txt单击第一个命令按钮:第一行的全部放到Text1.text , Text2.text , Text3.text单击第二个命令按钮:第二行的全部放到Text4.text , Text5.text , Text6.text求高手给源代码,和详细说明。万分感谢!!!
展开
2个回答
2013-08-31
展开全部
Private Sub Command1_Click() '第一行
Dim v Open "" & App.Path & "\1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, temp
x = x + 1
If x = 1 Then
v = Split(temp, " ")
For i = 0 To UBound(v)
Text1(i).Text = v(i)
Next
End If
Loop
Close #1
' MsgBox CStr(x) + "行"
End SubPrivate Sub Command2_Click() '第二行
Dim v Open "" & App.Path & "\1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, temp
x = x + 1
If x = 2 Then
v = Split(temp, " ")
For i = 0 To UBound(v)
Text2(i).Text = v(i)
Next
End If
Loop
Close #1
' MsgBox CStr(x) + "行"
End Sub
Dim v Open "" & App.Path & "\1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, temp
x = x + 1
If x = 1 Then
v = Split(temp, " ")
For i = 0 To UBound(v)
Text1(i).Text = v(i)
Next
End If
Loop
Close #1
' MsgBox CStr(x) + "行"
End SubPrivate Sub Command2_Click() '第二行
Dim v Open "" & App.Path & "\1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, temp
x = x + 1
If x = 2 Then
v = Split(temp, " ")
For i = 0 To UBound(v)
Text2(i).Text = v(i)
Next
End If
Loop
Close #1
' MsgBox CStr(x) + "行"
End Sub
2013-08-31
展开全部
最好把text文本做成控件数组,Dim a(9)
Private Sub Command1_Click()For j = 0 To 2
Text1(j).Text = a(j)
Next j
End SubPrivate Sub Command2_Click()
For j = 3 To 5
Text1(j).Text = a(j)
Next j
End SubPrivate Sub Form_Load()Open "E:\a.txt" For Input As #1
i = -1
Do While Not EOF(1)
i = i + 1
Input #1, a(i)Loop
Close #1
End Sub
Private Sub Command1_Click()For j = 0 To 2
Text1(j).Text = a(j)
Next j
End SubPrivate Sub Command2_Click()
For j = 3 To 5
Text1(j).Text = a(j)
Next j
End SubPrivate Sub Form_Load()Open "E:\a.txt" For Input As #1
i = -1
Do While Not EOF(1)
i = i + 1
Input #1, a(i)Loop
Close #1
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询