第2个回答 2009-01-16
1.直接读取文本
Private Sub Command1_Click()
Dim i As Integer
Dim a
Dim b
Open "c:\1.txt" For Binary As #1
a = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
b = Split(a, vbCrLf)
For i = 0 To UBound(b)
If b(i) = "" Then
Print b(i + 1)
End If
Next i
End Sub
2.使用文件系统读取文本
Private Sub Command1_Click()
Dim FSO As New FileSystemObject
Dim TS As TextStream
Set TS = FSO.OpenTextFile("C:1.txt", ForReading, True)
Do Until TS.ReadLine = ""
TS.ReadLine
Loop
Print TS.ReadLine
TS.Close
Set FSO = Nothing
End Sub
需要在工程中引用Microsoft scripting Runtime