How To: Close application during Start Up (VB.net)

  • Thread starter Thread starter Mr. B
  • Start date Start date
M

Mr. B

VB.net 2003 (standard)

In my application, within FORM1_LOAD, I check for various things (ie valide
user names, files, etc.). What I want to do is upon an event such as "No
Valide User Name Found" to pop up a warning message about the event and then
close the application.

I can do everything I want with the exception of a clean shut down during the
Form1_Load.

Back in VB6, I did this by:

Unload Me
Exit Sub

How do I do this in VB.net? I tried "Unload.Me" but it returns an error as
the application continues to try to run.

I'm sure it's a simple thing... but I've not found any reference to this in
all my books.

Regards,

Bruce
 
* Mr. B said:
In my application, within FORM1_LOAD, I check for various things (ie valide
user names, files, etc.). What I want to do is upon an event such as "No
Valide User Name Found" to pop up a warning message about the event and then
close the application.

\\\
Public Module Program
Public Sub Main()
If ... Then
Application.Run(New MainForm())
End If
End Sub
End Module
///

In the project properties, select 'Sub Main' as startup object.
 
I'd use Herfried's method. But if you absolutely have to load the form
first to check your validations, then you can use Me.Close() and/or
Application.Exit() to abandon loading.
______________________________
The Grim Reaper
 
With said:
\\\
Public Module Program
Public Sub Main()
If ... Then
Application.Run(New MainForm())
End If
End Sub
End Module
///

In the project properties, select 'Sub Main' as startup object.

Much appreciated!

Bruce
 
The Grim Reaper said:
I'd use Herfried's method. But if you absolutely have to load the form
first to check your validations, then you can use Me.Close() and/or
Application.Exit() to abandon loading.

Good point! Thank you!

Bruce
 
Back
Top