I have a function for a dialog which returns the dialog result back.
However, the value of the dialogresult changes from ok to cancel after the value is returned. How can i fix this?
this is the part where the dialog is called and the value from the dialog is returned.
Private Sub btnLogin_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnLogin.ItemClick
Dim loginDialog As New frmLogin
Dim result As DialogResult = Nothing
result = loginDialog.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
If My.Settings.User = "administrator" Then My.Settings.AccessCode = "admin"
My.Settings.AccessCode = ShippingClass.funcGetAcessCode(My.Settings.User)
Log_On()
End If
End Sub
This is the function that returns the dialog result.
Private Function OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Dim result As DialogResult
If txtPassword.Text = Nothing Or txtUserID.Text = Nothing Then
MessageBox.Show("Please check your user name and password", "Invalid Login")
Exit Function
End If
If ShippingClass.funcAuthenticate(txtUserID.Text, txtPassword.Text) = True Then
My.Settings.User = txtUserID.Text
doExit = True
Me.Close()
result = Windows.Forms.DialogResult.OK
Return result
Else
MessageBox.Show("Authentication Failed:" & vbCrLf & "The User ID and password you have entered does not match. Please check your login info and try again.", "Authentication Failure")
End If
End Function
****
btnLogin_ItemClick opens login dialog which returns a value as result back to btnLogin_ItemClick using the function OK_Click.
While debugging, the returning value after sucessful authentication should and is dialogresult.ok until it is passed back to btnLogin where the result value changes from 'Ok' to 'Cancel'