
Originally Posted by
matrik02
I read the files from vb,
How to pop up the messagebox when the files not found?
Code:
Dim txtVar1 As String
Open App.Path + "\Data.txt" For Input As #1
Input #1, txtVar1
Close #1
Recommend pro-active methods similar to what Dee-U posted.
What you posted is an example of a reactive method, allowing errors to occur to determine whether the file exists or not. The only thing missing is an On Error statement that would look like the following:
Code:
Dim txtVar1 As String
On Error Goto FailedToOpen
Open App.Path + "\Data.txt" For Input As #1
Input #1, txtVar1
Close #1
FailedToOpen:
If Err Then
MsgBox Err.Description
Err.Clear
End If
End Sub