VB Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim frmLogon As New LogonDialog()
Dim bLogonSuccessful As Boolean = False
Dim sFailureMessage As String
If frmLogon.ShowDialog() = DialogResult.OK Then
If frmLogon.txtUser.Text = "username" Then
If frmLogon.txtPassword.Text = "password" Then
bLogonSuccessful = True
Else
sFailureMessage = "Invalid Password!"
End If
Else
sFailureMessage = "Invalid User ID!"
End If
Else
sFailureMessage = "Logon Attempt Cancelled"
End If
If Not bLogonSuccessful Then
MessageBox.Show(sFailureMessage, "Logon Failed", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Close()
End If
End Sub
VB Code:
Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
Dim sUserID As String
Dim sPassword As String
If sUserID.Trim() = "" Then
MessageBox.Show("UserID cannot be blank" & "Please enter a proper UserID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtPassword.Select()
Else
Me.DialogResult = DialogResult.OK
End If
End Sub