Just change:
form2.Show()
To:
form2.ShowDialog()
From the documentation for ShowDialog():
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
Note that in the simplified example above, we are not capturing the return value of ShowDialog()
.
We could use the return value to determine if subsequent code should be executed or not:
If form2.ShowDialog() = DialogResult.OK Then
' ... do something in here ...
End If