I have an application that uses Sub Main as the Startup Object.
However, there are certain features available when enabling the
Application Framework (e.g. specifying splash screen, single instance
application, application-level events, etc.) that I have forfeited by
doing this. I'm not sure why one can't have a Startup Object of Sub
Main when enabling the Application Framework, but I'm sure there's a
good reason. So, here are my questions:
Right now the only thing I'm doing in the Sub Main is 1) creating some
global objects that will then be available to all forms, etc. in the
application, and 2) loading a login form where the user can login. I
then check to see if login was successful, and run the application if
it was. Here's the code:
<STAThread()> Public Sub Main()
CreateGlobalObjects()
' Let user attempt to login
Dim login As LoginForm = New LoginForm()
login.ShowDialog()
If (login.DialogResult = DialogResult.OK) Then
Application.Run(New MainForm())
End If
End Sub
QUESTION 1: Is there a way that I could accomplish the same thing but
do it using a form (LoginForm I'd presume) as the Startup Object?
QUESTION 2: What are the good reasons to use Sub Main rather than a
form as the Startup Object?
QUESTION 3: If I can't do the same thing using a form as the Startup
Object, how could I 1) implement a Splash screen, and 2) limit
application to single instance, bringing up existing instance if user
tries to run again?