|
Option Explicit
'一个简单的例子:
Const MODE_READ = 1
Const MODE_WRITE = 2
Const MODE_APPEND = 8
Private Sub Command1_Click()
'On Error Resume Next
Dim objFso
Dim objTs
Dim nLineCount As Integer
Dim strLine As String
nLineCount = 0
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objTs = objFso.OpenTextFile("D:\test.dat", MODE_READ)
Do While Not objTs.AtEndOfStream
nLineCount = nLineCount + 1
If nLineCount > 10 Then '行数大于10
strLine = objTs.ReadLine '读取当前行赋给strLine
'做些其他处理,比如从11行的第三列开始输出到窗体
If nLineCount = 11 Then
strLine = Mid(strLine, 3)
End If
Form1.Print strLine
End If
Loop
objTs.Close
Set objTs = Nothing
Set objFso = Nothing
End Sub
|