Set Form Visible = False then put Check_For_Dir() in then Form Load event.
If everything is OK the set Visible = True.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Check_For_Dir()
Me.Visible = True
End Sub
Public Sub Check_For_Dir()
Dim MyPath, MyName As String
MyPath = FilePath ' Set the path.
MyName = Dir(MyPath, FileAttribute.Directory) ' Retrieve the first
entry.
For i As Integer = 0 To 9999
If MessageBox.Show("Path " + FilePath + " not available, press
Yes to try again or No to Exit.", "Error", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
'Run Sub again
Check_For_Dir()
Else
Application.Exit
Exit Sub
End If
Next
End Sub
"Mike Johnson" <jo*****@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
The sub is being called from the Sub New(). If I can't use
Application.Exit() in this situation then how do I exit the application?
please help.
Public Sub Check_For_Dir()
Dim MyPath, MyName As String
MyPath = FilePath ' Set the path.
MyName = Dir(MyPath, FileAttribute.Directory) ' Retrieve the first
entry.
For i As Integer = 0 To 9999
If MessageBox.Show("Path " + FilePath + " not available, press
Yes to try again or No to Exit.", "Error", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
'Run Sub again
Check_For_Dir()
Else
Me.Close()
Exit Sub
End If
Next
End Sub