VB读取指定行的问题
Open filenamea For Input As #1
Do Until EOF(1)
Line Input #1, temps
n = n + 1
Loop
是这样的,想用N来控制,随意读取行,不知行不
不想这样,因为中间要等待其它模块的执行,所以想到用了用N
Open filenamea For Input As #1
Do Until EOF(1)
Line Input #1, temps
pass=temps
......
.....
.....
Loop
[解决办法]
行啊!
dim a()
Open filenamea For Input As #1
Do Until EOF(1)
Line Input #1, 每行
总行=总行 & 每行 & vbcrlf '[总行=所有的数据]
n=n+1 '[记录有多少条数据]
loop
close #1
a=split(总行,vbcrlf) '[把数据的每行放到数组a 中]
'[a(0)=第一行]
'[a(1)=第二行...类推]
'[要提取第3行的内容 找到 a(3-1)就可以了]
[解决办法]
Private Sub cmdOpen_Click()
Dim str As String
Dim str1 As String
Dim NextLine As String
Dim Txt_sj As String
Dim l As Integer
Dim n As Integer
n = Val(Text1)
CommonDialog1.ShowOpen
Text1 = " "
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Input #1, str1
str = str & str1 & Chr(13) & Chr(10)
Text1 = str1
l = l + 1
If l = 5 Then '指定读取的行数
Exit Do
End If
Loop
Close
Text3 = l
MsgBox "第 " & l & "行的内容 " & vbCrLf & Txt_sj, vbExclamation, "内容 " ' & str1
End Sub