Showing Forms

Any form—that is, any class that derives from the Form base class—can be shown in one of two ways. Here, it is shown modelessly:

Sub button1_Click(sender As Object, e As EventArgs)
  Dim myform As AnotherForm = New AnotherForm()
  myform.Show() ' Show form modelessly
End Sub

Here, a form is shown modally:

Sub button1_Click(sender As Object, e As System.EventArgs)
  Dim myform As AnotherForm = New AnotherForm()
  myform.ShowDialog()  ' Show form modally
End Sub

Form.Show shows the new form modelessly and returns immediately without creating any relationship between the currently active form and the new form. This means that the existing form can be closed, leaving the new form behind.[1] Form.ShowDialog, on the other hand, shows the ...

Get Windows Forms Programming in Visual Basic .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.