Calling another form from a click button in VB.NET

On a click button, I am trying to open another form. In VB6, the code was simply open form2, but it's not the same way in .NET. What is the best way to call another form from the click of a button in VB.NET?

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
' Show the form as a modaless window.
Dim x As Form2 = New Form2
x.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button2.Click
' Show this form as a dialog.
Dim x As Form3 = New Form3
x.ShowDialog(Me)
End Sub

Start the conversation

0 comments

Register

I agree to TechTarget’s Terms of Use, Privacy Policy, and the transfer of my information to the United States for processing to provide me with relevant information as described in our Privacy Policy.

Please check the box if you want to proceed.

I agree to my information being processed by TechTarget and its Partners to contact me via phone, email, or other means regarding information relevant to my professional interests. I may unsubscribe at any time.