Im using VB6. In Form.Load I make the text found in C:\test.txt fill Text1.text. My problem is if the file C:\test.txt doesn't exist, my program just errors. How can I make it so that I get a MsgBox or other notification if the file is missing, instead of a program crash? (So that I can continue on with the program, but just be notified that the file isn't there) Here's the code I'm using:
nFileNum = FreeFile
Open "C:\test.txt" For Input As nFileNum
lLineCount = 1
Do While Not EOF(nFileNum)
Line Input #nFileNum, sNextLine
sNextLine = sNextLine
sText = sText & sNextLine
Loop
Text1.Text = sText
Close nFileNum