1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| Private Sub CommandButton1_Click()
Dim sFileName As String
Dim iFileNum As Integer
Dim sBuf As String
Dim temp1 As String
Dim temp2 As String
temp1 = " "
' edit this:
sFileName = "C:\testFile.log"
' does the file exist? simpleminded test:
If Len(Dir$(sFileName)) = 0 Then
Exit Sub
End If
iFileNum = FreeFile()
Open sFileName For Input As iFileNum
Do While Not EOF(iFileNum)
Line Input #iFileNum, sBuf
temp2 = temp1
temp1 = temp2 & sBuf
' now you have the next line of the file in sBuf
' do something useful:
Debug.Print sBuf
Loop
TextBox1.Text = temp1
' close the file
Close iFileNum
End Sub |