Vb. net waiting for the closure of the second form before continuing

Is there a way in vb.net to pause the \ event function and wait until another form is closed to restrict

Example:

    Private Sub B1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1.Click

label1.text="Hello testing.." '1st function

form2.show() '2nd function

'MAKE FORM WAIT FOR FORM 2 TO CLOSE...
'THEN CONTINUE WITH THE NEXT FUNCTION

msgbox("Some function that was waiting in the event") '3rd function

end sub

The closest I can find in relation to what I want is an input field, but the input field is limited by what I want, although the dose is waiting, since I would like Form2 to function.

another suggestion was to loop until form 2 closed, however it is hacky and unprofessional as a solution (my opponent)

+4
source share
2 answers

Just change:

form2.show()

To:

form2.ShowDialog()
+12
source

Use ShowDialogit Shows the form as a modal dialog box.

DialogResult

Public Sub ShowMyDialogBox()
    Dim testDialog As New Form2()

    ' Show testDialog as a modal dialog and determine if DialogResult = OK.
    If testDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then
        ' Read the contents of testDialog TextBox.
        txtResult.Text = testDialog.TextBox1.Text
    Else
        txtResult.Text = "Cancelled"
    End If
    testDialog.Dispose()
End Sub 'ShowMyDialogBox

DialogResult , : button.DialogResult

+3

All Articles