by omidles (4 Submissions)
Category: Miscellaneous
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Thu 17th November 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Open TXT file
On Error GoTo Err_Not_Found
Dim FileName, Temp, Total As String
Dim FileNumber As Integer
FileName = InputBox("Enter the path for a text file", _
"Open", "C:\test.txt", 0, 0)
If FileName = "" Then Exit Sub
FileNumber = FreeFile
Open FileName For Input As FileNumber
While Not EOF(FileNumber)
Line Input #FileNumber, Temp
Total = Total + Temp + Chr(10) + Chr(13)
Wend
Close FileNumber
Text1.Text = Total
Exit Sub
Err_Not_Found:
MsgBox Err.Description & vbCrLf & Err.Number
End Sub