哪位高手知道怎么用vb6.0从一个txt文件中提取数据?
3个回答
展开全部
'下面是个例子,具体更改要根据你的文件结构来改,你可以看看怎么操作文件
dim DataFileName as string'文件路径及文件名
dim StrArray() as string'保存数据
datafilename=.....文件名初始化,你自己搞
Open DataFileName For Input As #1
Do While Not EOF(1)
Line Input #1, LineData
StrArray = Split(LineData, " ")
'这里加入给文本框赋值的代码
text1.text=strarray(0)
text2.text=strarray(1)
.....
'
Close #1
---------------------------
热心帮助每一个人,互相学习.有疑问请到我的blog里留言!
http://hi.baidu.com/privateblog
dim DataFileName as string'文件路径及文件名
dim StrArray() as string'保存数据
datafilename=.....文件名初始化,你自己搞
Open DataFileName For Input As #1
Do While Not EOF(1)
Line Input #1, LineData
StrArray = Split(LineData, " ")
'这里加入给文本框赋值的代码
text1.text=strarray(0)
text2.text=strarray(1)
.....
'
Close #1
---------------------------
热心帮助每一个人,互相学习.有疑问请到我的blog里留言!
http://hi.baidu.com/privateblog
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
首先你要将Text控件的MultiLine属性设置为True ,该属性运行时只读。
Dim FileName As String '文件的全路径名称,比如"C;\Data\Demo.txt"
Dim FileNum As Long '可用的文件号
Dim Txt As String '文件缓冲
FileName = "C:\Data\demo.txt"
FileNum = FreeFile
'一种快速导入文本文件内容的方法
Open FileName For Binary As FileNum
Txt = String(LOF(FileNum), 0)
Get #FileNum, , Txt
Close FileNum
Text1.Text = Txt
Txt = ""
Dim FileName As String '文件的全路径名称,比如"C;\Data\Demo.txt"
Dim FileNum As Long '可用的文件号
Dim Txt As String '文件缓冲
FileName = "C:\Data\demo.txt"
FileNum = FreeFile
'一种快速导入文本文件内容的方法
Open FileName For Binary As FileNum
Txt = String(LOF(FileNum), 0)
Get #FileNum, , Txt
Close FileNum
Text1.Text = Txt
Txt = ""
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim FileName As String
Dim s1 As String
Text1.Text = ""
FileName = App.Path + "\" + "1.txt" '----假设文本文件的名为1.txt
Open FileName For Input As #1
Do While Not EOF(1)
Line Input #1, s1
Text1.Text = s1
Loop
Close #1
End Sub
Dim FileName As String
Dim s1 As String
Text1.Text = ""
FileName = App.Path + "\" + "1.txt" '----假设文本文件的名为1.txt
Open FileName For Input As #1
Do While Not EOF(1)
Line Input #1, s1
Text1.Text = s1
Loop
Close #1
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询