[vb.net] How to open up a form from another form in VB.NET?

This I thought would be easy. I have not used VB.NET all that much, and I am trying to open up a form from a button click. The form will not show and I get a null exception error.

What is wrong with the code?

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
    Dim A
    A = AboutBox1
    A.Show()
End Sub

This question is related to vb.net

The answer is


You can also use showdialog

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) _
                      Handles Button3.Click

     dim mydialogbox as new aboutbox1
     aboutbox1.showdialog()

End Sub

You could use:

Dim MyForm As New Form1
MyForm.Show()

or rather:

MyForm.ShowDialog()

to open the form as a dialog box to ensure that user interacts with the new form or closes it.


You may like to first create a dialogue by right clicking the project in solution explorer and in the code file type

dialogue1.show()

that's all !!!