StealthRT
StealthRT

Reputation: 10542

Waiting on form return vb.net

What is the proper way to call up a form and wait until it recieves a replay before moving onto the next code step?

Example code is:

Public isLogedIn As Boolean = False

Private Sub Reprint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles  ReprintButton.Click
If isLogedIn = False Then
        Using lf As New frmLogin()
            lf.ShowDialog()
.....

Now lf is the login form that waits for the users password and then, depending on if its correct or not when they hit OK it should send back a true or false (isLogedIn).

Currently i do not know how to have the code wait until it receives something from the login form before moving onto the next code.

If i use my old code here:

 Do Until isLogedIn = True
    isLogedIn = isLogedIn
    intX = intX + 1
 Loop

It never ends if the user puts in a false login password so it just keeps waiting....

Any help would be great!

David

Upvotes: 1

Views: 1392

Answers (1)

KV Prajapati
KV Prajapati

Reputation: 94645

You may use return type of ShowDialog() method - DialogResult. In Login form you have to set DialogResult property of Buttons. For more info take a look at - Dialog Boxes in Windows Forms and Essential Code for Windows Forms Dialog Boxes.

Upvotes: 2

Related Questions