Results 1 to 3 of 3

Thread: Logon Validation

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    46

    Logon Validation

    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:
    1. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim frmLogon As New LogonDialog()
    3.         Dim bLogonSuccessful As Boolean = False
    4.         Dim sFailureMessage As String
    5.  
    6.         If frmLogon.ShowDialog() = DialogResult.OK Then
    7.  
    8.             If frmLogon.txtUser.Text = "username" Then
    9.                 If frmLogon.txtPassword.Text = "password" Then
    10.                     bLogonSuccessful = True
    11.                 Else
    12.                     sFailureMessage = "Invalid Password!"
    13.                 End If
    14.             Else
    15.                 sFailureMessage = "Invalid User ID!"
    16.             End If
    17.         Else
    18.             sFailureMessage = "Logon Attempt Cancelled"
    19.         End If
    20.  
    21.         If Not bLogonSuccessful Then
    22.             MessageBox.Show(sFailureMessage, "Logon Failed", MessageBoxButtons.OK, MessageBoxIcon.Error)
    23.             Me.Close()
    24.         End If
    25.     End Sub

    Logon Form:

    VB Code:
    1. Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
    2.         Dim sUserID As String
    3.         Dim sPassword As String
    4.  
    5.         If sUserID.Trim() = "" Then
    6.             MessageBox.Show("UserID cannot be blank" & "Please enter a proper UserID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    7.             txtPassword.Select()
    8.         Else
    9.             Me.DialogResult = DialogResult.OK
    10.         End If
    11.     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*
    Last edited by longshot_zero; Oct 27th, 2002 at 10:53 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width