Hey guys,
I'm very new to VB.net and am having a problem with a logon screen.
Here's the code i am using:
Main Form:
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
Logon Form:
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
This is the error i am getting when i click OK on the logon form:
Code:An unhandled exception of type 'System.NullReferenceException' occurred in login.exe Additional information: Object reference not set to an instance of an object.
__________
Any help would be greatly appreciated
Thanks guys
Longshot
*edit: vB code added*




Reply With Quote