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

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
 
H

Herfried K. Wagner [MVP]

* 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.
 
T

The Grim Reaper

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
 
M

Mr. B

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
 
M

Mr. B

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top