如何在VB中把文本文件以指定格式读入VB中?
文本文件的内容入下:1985,姓名,工号,介绍人,职位,地址,电话1985,姓名,工号,介绍人,职位,地址,电话1985,姓名,工号,介绍人,职位,地址,电话有300行要...
文本文件的内容入下:
1985,姓名,工号,介绍人,职位,地址,电话
1985,姓名,工号,介绍人,职位,地址,电话
1985,姓名,工号,介绍人,职位,地址,电话
有300行
要怎么样才能对应的读到text(0-6).text这个控件里去呢?
在线等急!! 展开
1985,姓名,工号,介绍人,职位,地址,电话
1985,姓名,工号,介绍人,职位,地址,电话
1985,姓名,工号,介绍人,职位,地址,电话
有300行
要怎么样才能对应的读到text(0-6).text这个控件里去呢?
在线等急!! 展开
3个回答
2014-03-14
展开全部
首先要把text(0-6)的multiline属性设为ture,再加个垂直滚动条(scrollbars设为vertical),不然300行显示不下!实现代码:
Open "c:\1.txt" For Input As #1 '文本文件的路径根据你的实际情况!
Do Until EOF(1)
Line Input #1, n
Text(0 - 6).Text = Text(0 - 6).Text & Chr(13) & Chr(10) & n
Loop
Close #1
Open "c:\1.txt" For Input As #1 '文本文件的路径根据你的实际情况!
Do Until EOF(1)
Line Input #1, n
Text(0 - 6).Text = Text(0 - 6).Text & Chr(13) & Chr(10) & n
Loop
Close #1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-03-14
展开全部
dim p(0 to 6) as string
open app.path+"\data.txt" for input #1
do while not eof(1)
line input #1,ss
p=split(ss,",") '将以逗号分割的字段读入数组中
if p(0)="1988" then ''根据相关的字段查询并显示
for i=0 to 6
text(i).text=p(i)
next
end if
loop
close#1
open app.path+"\data.txt" for input #1
do while not eof(1)
line input #1,ss
p=split(ss,",") '将以逗号分割的字段读入数组中
if p(0)="1988" then ''根据相关的字段查询并显示
for i=0 to 6
text(i).text=p(i)
next
end if
loop
close#1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-03-14
展开全部
Dim n As String
Dim i As Long
Open "c:\1.txt" For Input As #1
Do Until EOF(1)
Line Input #1, n
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(0).Text = Text(0).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(1).Text = Text(1).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(2).Text = Text(2).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(3).Text = Text(3).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(4).Text = Text(4).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(5).Text = Text(5).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
Text(6).Text = Text(6).Text & vbCrLf & n
Loop
Close #1
Dim i As Long
Open "c:\1.txt" For Input As #1
Do Until EOF(1)
Line Input #1, n
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(0).Text = Text(0).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(1).Text = Text(1).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(2).Text = Text(2).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(3).Text = Text(3).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(4).Text = Text(4).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
For i = 1 To Len(n)
If Mid(n, i, 1) = "," Then
Text(5).Text = Text(5).Text & vbCrLf & Left(n, i - 1)
n = Mid(n, i + 1)
Exit For
End If
Next
Text(6).Text = Text(6).Text & vbCrLf & n
Loop
Close #1
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询