My little application has a text field and 2 bottons.
Writing a passowrd and clicking on "Avvia" my application checks if the password is correct, if it is looks for the file "test.txt", if the file exists it is renamed as test.exe and loaded.
The problem comes if the file doesn't exists, my application gives correctly an error message as you can read in VerifyFile sub, but then it goes on with the line that try to rename the file and an error occurs closing my application as I press "OK".
How can I say to Avvia_Click() to do nothing if the file has not been found by VerifyFile?
CODE
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub VerifyFile(FileName As String)
On Error Resume Next
Open FileName For Input As #1 'Apre lo specifico file
If Err Then
MsgBox ("File " & FileName & " not found")
Exit Sub
End If
Close #1
End Sub
Private Sub Avvia_Click()
Dim a
If (Text1.Text = "password") Then
Call VerifyFile("test.txt")
Name ".\test.txt" As ".\test.exe"
Sleep 3000
a = Shell(".\test.exe", 1)
End If
End Sub
Private Sub Chiudi_Click()
Name ".\test.exe" As ".\test.txt"
End Sub