close a form and open another one at same time?

ssfftt

Well-known member
Joined
Oct 27, 2005
Messages
163
Programming Experience
1-3
[solved]close a form and open another one at same time?

I have 2 forms: Login and Registerwhen i click on register button on Login form, I use:
VB.NET:
        Dim frmUserRegistration As New frmUserRegistration        frmUserRegistration.Show()        Me.Hide()
When i close form Register, i want it returns to Login form, i tried frmUserRegistration.close and frmLogin.show. at runtime something like an infinite loop happend. can anyone help in code plz?
 
Last edited:
I think i know how to implement the code, just not sure where to put the code. I put it on frmUserRegistration's closing event, it didnt work.
 
you could do something like this:
VB.NET:
Dim frmUserRegistration As New frmUserRegistration
Me.Hide()
frmUserRegistration.ShowDialog()
Me.Show()
 
JuggaloBrotha said:
you could do something like this:
VB.NET:
Dim frmUserRegistration As New frmUserRegistration
Me.Hide()
frmUserRegistration.ShowDialog()
Me.Show()

Thanks JuggaloBrotha, but I dont think u understood me or I wasnt clear enough. anyway, I tried to put the code in closing event of the form:

VB.NET:
    Private Sub frmPWReminder_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Dim frmLogin As New frmLogin
        frmLogin.Show()
        Me.Close()
    End Sub

its wrong, maybe i should put it under Closed event?
 
sorry if i didnt specify where to put the code i suggested

put this code in the Register button's click event on the login form:
VB.NET:
Dim frmUserRegistration As New frmUserRegistration
Me.Hide()
frmUserRegistration.ShowDialog()
Me.Show()
 
interesting code, i couldnt quite understand the logic, and how it works. but anyway, it worked perfectly. thx JuggaloBrotha.~I will take some more time try to figure out the myth :)
 
I added "[solved]" @ begining of the title of this post and put a thumb up pic, how come when i go back to the posts list, it still has the question mark pic which shouldnt exist anymore?
 
there are still some bugs like that in the forum software, dont worry about it

also the ShowDialog method of the form means that the form will open and run and the code on the login form stops executing until that form is closed

that's why it works
 
Back
Top