如何用VB读取TXT文件中的数据,TXT文件的每个数据用逗号分开,但字符长度不同.
2个回答
2013-07-08
展开全部
用Split Dim s As String
Dim sp() As String
Open "c:\1.txt" For Input As #1 '比如打开"c:\1.txt",内容是:5,56,5855,455665
While Not EOF(1)
Line Input #1, s
Wend
Close #1
sp = Split(s, ",")'执行后sp的元素内容就分别是5、56、5855、455665
Dim sp() As String
Open "c:\1.txt" For Input As #1 '比如打开"c:\1.txt",内容是:5,56,5855,455665
While Not EOF(1)
Line Input #1, s
Wend
Close #1
sp = Split(s, ",")'执行后sp的元素内容就分别是5、56、5855、455665
2013-07-08
展开全部
Private Sub Command1_Click()
Dim a As String
Open "c:\2.txt" For Input As #1
Do Until EOF(1)
Line Input #1, a
a = Right(a, Len(a) - InStr(a, ","))
a = Left(a, InStr(a, ",") - 1)
Text2.Text = Text2.Text & a & vbCrLf
Loop
Close #1
End Sub
Dim a As String
Open "c:\2.txt" For Input As #1
Do Until EOF(1)
Line Input #1, a
a = Right(a, Len(a) - InStr(a, ","))
a = Left(a, InStr(a, ",") - 1)
Text2.Text = Text2.Text & a & vbCrLf
Loop
Close #1
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询