help with MyApplication Startup

sgtmoody

Member
Joined
Jul 10, 2007
Messages
5
Programming Experience
1-3
so I'm making a simple program in vb.net 2005 I have the main form setup as the startup form and a few other forms. basically I want to load one of two forms below before the main form loads. I have set up some simple code in the ApplicationsEvents.vb MyApplication_Startup to figure out which form to load
VB.NET:
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
            if //simple if statement
               show form1
            Else
               show form2
            End If
        End Sub
my question is how do I get the main form to hide. as it is right now it works but the main form loads as well. so basically I get for example form1 and the main form to show when I only want form1 to show. how do I hide the main page when the application loads?

any help would be much appreciated thanks.
 
If you just want another form to load before the form1, then you can change the start form at: Project --> then the last one there, named [program name] properties. There it says: startup form.
 
not exactly what I want to do but I did find a work around. rather then just load the other forms I made the form I wanted to load first the main form at start up before the main form I specified in the project is even loaded.
VB.NET:
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
            if //simple if statement
               me.mainForm = form1
            Else
               me.mainForm = form2
            End If
        End Sub
then when I close the form specified in the project as the main form I just put this
VB.NET:
Application.exit() //closes all the forms and shuts down the application
this way it doesn't matter which form is the mian it just closes all the forms.
 
Back
Top