如何使用VB把txt文件中的数字一个个读取出来
1个回答
展开全部
'txt原始数据与运行后验证情况如上图,代码如下,需要仔细研究下
Private Sub Command3_Click()
Dim hang() As String
Dim lie() As String
Dim zhuge() As String
Dim i, a, b, c, j As Integer
c = 1
Open "d:\test.txt" For Input As #1
While Not EOF(1)
ReDim Preserve hang(i)
Line Input #1, hang(i)
i = i + 1
Wend
Close #1
For a = 0 To UBound(hang)
lie = Split(hang(a), " ")
For b = 0 To UBound(lie)
ReDim Preserve zhuge(c)
zhuge(c) = lie(b)
c = c + 1
Next b
Next a
For j = 1 To UBound(zhuge) '打印验证
Print zhuge(j)
Next j
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询