VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Open TXT file

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

Rate 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

Download this snippet    Add to My Saved Code

Open TXT file Comments

No comments have been posted about Open TXT file. Why not be the first to post a comment about Open TXT file.

Post your comment

Subject:
Message:
0/1000 characters