From: "Johnnie Miami" <Johnnie on
I'm using VB.Net 2005 beta 2 and have my login form (login.vb) specified as
the startup form. If the user is successful logging in, I call my main form
(main.vb). This all works fine but the problem is that the login form stays
open. I put a me.close (in the login form) after opening the main form but
that seems to close everything and the main form is not displayed.

I thought I could call a Sub Main() that calls the login form, closes it
then calls the main form. However, I don't see where I can call the sub Main
since the project property only gives you an option to call a Startup Form.

Thanks!
From: Ken Tucker [MVP] on
Hi,

I tested this with VS.Net 2005 RC but I believe it will work with
beta 2. First add a module with a public sub main. Second open myproject in
the solution explorer and uncheck enable application framework. You now
should be able to set the startup object to sub main.

Ken
------------------
"Johnnie Miami" <Johnnie Miami(a)discussions.microsoft.com> wrote in message
news:0D1746CA-4B83-4D93-9403-F0F41B49DFB1(a)microsoft.com...
> I'm using VB.Net 2005 beta 2 and have my login form (login.vb) specified
> as
> the startup form. If the user is successful logging in, I call my main
> form
> (main.vb). This all works fine but the problem is that the login form
> stays
> open. I put a me.close (in the login form) after opening the main form
> but
> that seems to close everything and the main form is not displayed.
>
> I thought I could call a Sub Main() that calls the login form, closes it
> then calls the main form. However, I don't see where I can call the sub
> Main
> since the project property only gives you an option to call a Startup
> Form.
>
> Thanks!


From: Ken Tucker [MVP] on
Hi,

Forgot to mention. VB.Net has some new events if you enable the
application framework. There will be a button in my project that says view
application events. If you press the button it will add
applicationevents.vb. You can add code to the application startup event
which shows the login form. If the user is not authorized to use the app
you can cancel the startup.

Namespace My

' The following events are availble for MyApplication:
'
' Startup: Raised when the application starts, before the startup form
is created.
' Shutdown: Raised after all application forms are closed. This event
is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an unhandled
exception.
' StartupNextInstance: Raised when launching a single-instance
application and the application is already active.
' NetworkAvailabilityChanged: Raised when the network connection is
connected or disconnected.
Partial Friend Class MyApplication

Private Sub MyApplication_NetworkAvailabilityChanged(ByVal sender As
Object, ByVal e As Microsoft.VisualBasic.Devices.NetworkAvailableEventArgs)
Handles Me.NetworkAvailabilityChanged
' event raised when you connect or disconnect from a network
MessageBox.Show(e.IsNetworkAvailable.ToString)
End Sub

Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As
Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles
Me.Startup
Dim dr As DialogResult = LoginForm1.ShowDialog
' In my app the loginform returns ok if the user is authorized
e.Cancel = dr <> DialogResult.OK
End Sub
End Class

End Namespace


Ken
------------------
"Ken Tucker [MVP]" <vb2ae(a)bellsouth.net> wrote in message
news:ef0Vp4iwFHA.2540(a)TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I tested this with VS.Net 2005 RC but I believe it will work with
> beta 2. First add a module with a public sub main. Second open myproject
> in the solution explorer and uncheck enable application framework. You
> now should be able to set the startup object to sub main.
>
> Ken
> ------------------
> "Johnnie Miami" <Johnnie Miami(a)discussions.microsoft.com> wrote in message
> news:0D1746CA-4B83-4D93-9403-F0F41B49DFB1(a)microsoft.com...
>> I'm using VB.Net 2005 beta 2 and have my login form (login.vb) specified
>> as
>> the startup form. If the user is successful logging in, I call my main
>> form
>> (main.vb). This all works fine but the problem is that the login form
>> stays
>> open. I put a me.close (in the login form) after opening the main form
>> but
>> that seems to close everything and the main form is not displayed.
>>
>> I thought I could call a Sub Main() that calls the login form, closes it
>> then calls the main form. However, I don't see where I can call the sub
>> Main
>> since the project property only gives you an option to call a Startup
>> Form.
>>
>> Thanks!
>
>


From: Johnnie Miami on
Thanks Ken. When I uncheck "Enable Application Framework" I can then select
the Sub Main as the startup. However, I loose access to ensuring that I only
have one instance of my application started and the splash screen. This
seems pretty straightforward....any ideas why its not?????

Thanks!

"Ken Tucker [MVP]" wrote:

> Hi,
>
> Forgot to mention. VB.Net has some new events if you enable the
> application framework. There will be a button in my project that says view
> application events. If you press the button it will add
> applicationevents.vb. You can add code to the application startup event
> which shows the login form. If the user is not authorized to use the app
> you can cancel the startup.
>
> Namespace My
>
> ' The following events are availble for MyApplication:
> '
> ' Startup: Raised when the application starts, before the startup form
> is created.
> ' Shutdown: Raised after all application forms are closed. This event
> is not raised if the application terminates abnormally.
> ' UnhandledException: Raised if the application encounters an unhandled
> exception.
> ' StartupNextInstance: Raised when launching a single-instance
> application and the application is already active.
> ' NetworkAvailabilityChanged: Raised when the network connection is
> connected or disconnected.
> Partial Friend Class MyApplication
>
> Private Sub MyApplication_NetworkAvailabilityChanged(ByVal sender As
> Object, ByVal e As Microsoft.VisualBasic.Devices.NetworkAvailableEventArgs)
> Handles Me.NetworkAvailabilityChanged
> ' event raised when you connect or disconnect from a network
> MessageBox.Show(e.IsNetworkAvailable.ToString)
> End Sub
>
> Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As
> Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles
> Me.Startup
> Dim dr As DialogResult = LoginForm1.ShowDialog
> ' In my app the loginform returns ok if the user is authorized
> e.Cancel = dr <> DialogResult.OK
> End Sub
> End Class
>
> End Namespace
>
>
> Ken
> ------------------
> "Ken Tucker [MVP]" <vb2ae(a)bellsouth.net> wrote in message
> news:ef0Vp4iwFHA.2540(a)TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I tested this with VS.Net 2005 RC but I believe it will work with
> > beta 2. First add a module with a public sub main. Second open myproject
> > in the solution explorer and uncheck enable application framework. You
> > now should be able to set the startup object to sub main.
> >
> > Ken
> > ------------------
> > "Johnnie Miami" <Johnnie Miami(a)discussions.microsoft.com> wrote in message
> > news:0D1746CA-4B83-4D93-9403-F0F41B49DFB1(a)microsoft.com...
> >> I'm using VB.Net 2005 beta 2 and have my login form (login.vb) specified
> >> as
> >> the startup form. If the user is successful logging in, I call my main
> >> form
> >> (main.vb). This all works fine but the problem is that the login form
> >> stays
> >> open. I put a me.close (in the login form) after opening the main form
> >> but
> >> that seems to close everything and the main form is not displayed.
> >>
> >> I thought I could call a Sub Main() that calls the login form, closes it
> >> then calls the main form. However, I don't see where I can call the sub
> >> Main
> >> since the project property only gives you an option to call a Startup
> >> Form.
> >>
> >> Thanks!
> >
> >
>
>
>
From: Ken Tucker [MVP] on
Hi,

The application framework take care of that for you. You are
probably better off using the application startup event instead of sub main
if you need the features of the application framework.

Ken
-----------------
"Johnnie Miami" <JohnnieMiami(a)discussions.microsoft.com> wrote in message
news:3136F44F-191C-4EF3-9E4C-A8EEE0FE5565(a)microsoft.com...
> Thanks Ken. When I uncheck "Enable Application Framework" I can then
> select
> the Sub Main as the startup. However, I loose access to ensuring that I
> only
> have one instance of my application started and the splash screen. This
> seems pretty straightforward....any ideas why its not?????
>
> Thanks!
>
> "Ken Tucker [MVP]" wrote:
>
>> Hi,
>>
>> Forgot to mention. VB.Net has some new events if you enable
>> the
>> application framework. There will be a button in my project that says
>> view
>> application events. If you press the button it will add
>> applicationevents.vb. You can add code to the application startup event
>> which shows the login form. If the user is not authorized to use the app
>> you can cancel the startup.
>>
>> Namespace My
>>
>> ' The following events are availble for MyApplication:
>> '
>> ' Startup: Raised when the application starts, before the startup
>> form
>> is created.
>> ' Shutdown: Raised after all application forms are closed. This
>> event
>> is not raised if the application terminates abnormally.
>> ' UnhandledException: Raised if the application encounters an
>> unhandled
>> exception.
>> ' StartupNextInstance: Raised when launching a single-instance
>> application and the application is already active.
>> ' NetworkAvailabilityChanged: Raised when the network connection is
>> connected or disconnected.
>> Partial Friend Class MyApplication
>>
>> Private Sub MyApplication_NetworkAvailabilityChanged(ByVal sender
>> As
>> Object, ByVal e As
>> Microsoft.VisualBasic.Devices.NetworkAvailableEventArgs)
>> Handles Me.NetworkAvailabilityChanged
>> ' event raised when you connect or disconnect from a network
>> MessageBox.Show(e.IsNetworkAvailable.ToString)
>> End Sub
>>
>> Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e
>> As
>> Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles
>> Me.Startup
>> Dim dr As DialogResult = LoginForm1.ShowDialog
>> ' In my app the loginform returns ok if the user is
>> authorized
>> e.Cancel = dr <> DialogResult.OK
>> End Sub
>> End Class
>>
>> End Namespace
>>
>>
>> Ken
>> ------------------
>> "Ken Tucker [MVP]" <vb2ae(a)bellsouth.net> wrote in message
>> news:ef0Vp4iwFHA.2540(a)TK2MSFTNGP09.phx.gbl...
>> > Hi,
>> >
>> > I tested this with VS.Net 2005 RC but I believe it will work
>> > with
>> > beta 2. First add a module with a public sub main. Second open
>> > myproject
>> > in the solution explorer and uncheck enable application framework. You
>> > now should be able to set the startup object to sub main.
>> >
>> > Ken
>> > ------------------
>> > "Johnnie Miami" <Johnnie Miami(a)discussions.microsoft.com> wrote in
>> > message
>> > news:0D1746CA-4B83-4D93-9403-F0F41B49DFB1(a)microsoft.com...
>> >> I'm using VB.Net 2005 beta 2 and have my login form (login.vb)
>> >> specified
>> >> as
>> >> the startup form. If the user is successful logging in, I call my
>> >> main
>> >> form
>> >> (main.vb). This all works fine but the problem is that the login form
>> >> stays
>> >> open. I put a me.close (in the login form) after opening the main
>> >> form
>> >> but
>> >> that seems to close everything and the main form is not displayed.
>> >>
>> >> I thought I could call a Sub Main() that calls the login form, closes
>> >> it
>> >> then calls the main form. However, I don't see where I can call the
>> >> sub
>> >> Main
>> >> since the project property only gives you an option to call a Startup
>> >> Form.
>> >>
>> >> Thanks!
>> >
>> >
>>
>>
>>