Private Sub Command1_Click()
Dim i As Long
Dim s As String
Open "C:\aa.txt" For Input As #1
i = 0
Do Until EOF(1)
i = i + 1
Line Input #1, s
If i = 9 Then '读第九行
Print s
End If
Loop
Close #1
End Sub
Dim i As Long
Dim s As String
Open "C:\aa.txt" For Input As #1
i = 0
Do Until EOF(1)
i = i + 1
Line Input #1, s
If i = 9 Then '读第九行
Print s
End If
Loop
Close #1
End Sub
在对那个数组进行操作
别以为VB会把所有的事情做好
那人们学边还有什么用?
还能赚到钱?!
Dim LoadBytes() As Byte
dim LineStr() as stringTempFile=FreeFile
Open 文件名 For Binary As #TempFile
Redim LoadBytes(1 To Lof(TempFile)) As Byte
Get #TempFile,,LoadBytes
Close TempFileLineStr=Split(StrConv(LoadBytes,vbUniCode),vbCrlf)第n行的数据=LineStr(n-1)
dim k as string
open "file" for input as #1
for i=1 to j
input #1,k
next i
close #1
'此时k中就应该是第j行的
Dim i As Long
Dim s As String
Open "C:\aa.txt" For Input As #1
i = 0
Do Until EOF(1)
i = i + 1
Line Input #1, s
If i = 9 Then '读第九行
Print s
Exit Do '避免浪费
End If
Loop
Close #1
End Sub
打工好辛苦
★★★★★
钞票好难赚
★★★★★
编程好伤神
★★★★★
光阴好易混
★★★★★
'功能说明:文本文件(MyTextFile)写入(MyData)中
'写入跟踪数据
MyPath = App.Path
MyFile = MyPath & "\" & MyTextFile
i=0
filenum = FreeFile
Open MyFile For Input As filenum
do while Not EOF(filenum) Then '这里只读入第一行
i=i+1
Dim MyData As String
Line Input #filenum, MyData
if i=你要的行 then
temp=MyData
exit do
end if
loop
Close filenum