By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,414 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,414 IT Pros & Developers. It's quick & easy.

Help with startup form.....

P: n/a
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!
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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 Mi***@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.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!

Nov 21 '05 #2

P: n/a
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.NetworkAvailableEven tArgs)
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.StartupE ventArgs) 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]" <vb***@bellsouth.net> wrote in message
news:ef**************@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 Mi***@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.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!


Nov 21 '05 #3

P: n/a
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.NetworkAvailableEven tArgs)
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.StartupE ventArgs) 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]" <vb***@bellsouth.net> wrote in message
news:ef**************@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 Mi***@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.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!



Nov 21 '05 #4

P: n/a
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" <Jo**********@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.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.NetworkAvailableEven tArgs)
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.StartupE ventArgs) 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]" <vb***@bellsouth.net> wrote in message
news:ef**************@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 Mi***@discussions.microsoft.com> wrote in
> message
> news:0D**********************************@microsof t.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!
>
>


Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.