Display windows form as dialog in vb.net

In this example we will learn that how to use showdialog method in vb.net to display a windows form.
when we use this method then form will be open as dialog.

You can use this method to display a modal dialog box in your application. When this method is called, the code following it is not executed until after the dialog box is closed.


Suppose you have two windows form (Form1 and Form2), Form1 has one button named Button1. And you need to display Form2 as dialog on the click of Button1 of the Form1.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim objForm As New Form2
End Sub