Opening Another Form

ayozzhero

Well-known member
Joined
Apr 6, 2005
Messages
186
Location
Malaysia
Programming Experience
1-3
This is my code:

Dim oForm As New frmLogin
oForm.Show()
Me.Close()

The problem is, when 'Me.Close()' is executed, frmLogin is also closed. How should I open another form, and then close the current form actually...

Thank you for helping.
 
what you will want to do is add a module to the project and in this module you'll want:

VB.NET:
'Module
Friend LoginForm as frmLogin

'Main Form
LoginForm = New frmLogin
LoginForm.Show
Me.Close
 
If Me is the startup object for your application then closing it will exit your app. If I'm not mistaken .NET 2.0 allows you to choose whether your app exits when the main form closes or when all forms close, but for now I think you will have to choose a new startup object. You can create a class with a Main procedure to open your forms.
 
Hi,

First off, JuggaloBrotha gave you good suggestion ... but i guess it was a bit confusing for you beside the fact it's so simple ... trust me.
btw, do you want to have a splash screen, login Form ... or simply close the form and open new one ... then, take a look at this example
Cheers ;)
 

Attachments

  • Forms.zip
    27.6 KB · Views: 210
yea, i did neglect the fact that Form1 was the startup object instead of using Sub Main

i didnt follow up on that either, there's tons of multiple forms threads on here as it is ;)
 
The starting point is Sub Main(), in which I wrote:

If isAlreadyRegistered() Then
'check whether valid version or not. If ok, runn app... if not check demo validity, if demo expired, terminate function
Select Case isValidApp()
Case True
isDemoMode = False
Application.Run(New frmLogin)
Case False
CheckFirstTimeRun()
If CheckDemoValidity() Then
Application.Run(New frmDemoStartScreen) 'run demo start screen
Else
isDemoExpired = True
Application.Run(New frmDenial) 'run denial screen then end
End If
End Select
Else
Application.Run(New frmRegistration) 'run registration screen
End If

I'll try the codes listed above. Thank you so much for helping.
 
Thank you everybody for your help...

I just had the opportunity to go through the codes Kulrom to put in my new project. It was so easy if only I knew how to do it the correct way... and it is not the only thing I learned. I saw you using:
Application.Exit()

Previously, I used 'End' to end my application and I feel like it takes around one or two seconds before it actually closes the application.

once again... thank you for helping and increasing my programming experience
 
Back
Top