Results 1 to 4 of 4

Thread: NullException Error help.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83

    NullException Error help.

    With the code below Im getting NullException with the If statements. Where If the user enters nothing "" then the
    message box shows. Any Idea's what Im doing wrong?

    Code:
    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
    
            Dim sUserID As String
            Dim sPass As String
    
            If sUserID.Trim() = "" Then
    
                MessageBox.Show("UserID cannot be blank," _
                & "Please endter a proper UserID.", "Error", _
                MessageBoxButtons.OK, MessageBoxIcon.Error)
                txtUserID.Select()
            Else
                If sPass.Trim() = "" Then
                    MessageBox.Show("Password cannot be blank," _
                    & "Please enter a proper password.", "Error", _
                    MessageBoxButtons.OK, MessageBoxIcon.Error)
                    txtPass.Select()
                Else
                    Me.DialogResult = DialogResult.OK
                End If
            End If
        End Sub
    Last edited by Jes|er; Feb 23rd, 2002 at 08:20 PM.
    12/32/84 - I need some code to make me a sandwhich.

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Wouldn't you have to get values that are contained
    in the text boxes and store them in two variables then
    test for empty strings? You seem to have declared two
    string variables but i see nowhere in your code that
    takes the data that is being held in the texboxes and
    transfers it to the variables.
    Code:
        Dim sUserID As String
        Dim sPass As String
        If sUserID.Trim() = "" Then

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83
    Doh!


    Well, its been a long day. Atleast that's the excuse I'm
    using. Thanks!
    12/32/84 - I need some code to make me a sandwhich.

  4. #4

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