A bit of confusion

what to do

I have a form1 in that their is a button by name "login"
by clicking on the button "login" the form2 will be shown
in a form2 their is username and password text boxes and two button one is "ok" and another one is "cancel"

by clicking on a button "cancel" it should return to the form1
how to link the button "cancel"

Recommended Answers

All 4 Replies

Is form1 still open while Form2 is open? If so then simply do Me.Close in the cancel button.click event.

no form1 is been hiden

and i tried many times by adding me.close i was unable to close

Is form1 still open while Form2 is open? If so then simply do Me.Close in the cancel button.click event.

can u suggest me how to do it please

try this:

In your main form use this to show the login form:

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
		Me.Hide()
		Dim frm As New Form2()
		frm.ShowDialog(Me)
	End Sub

In your Form2 "cancel" click use this:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
		If Me.Owner IsNot Nothing Then
			Me.owner.Show()
		End If

		Me.Close()
	End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.