Results 1 to 8 of 8

Thread: why doesn't this work!? (resolved)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Utah
    Posts
    397

    why doesn't this work!? (resolved)

    VB Code:
    1. Private sub Command1_Click()
    2. Dim user2 as string
    3. Dim pass2 as string
    4.  
    5. user2 = bob
    6. pass2 = hi
    7.  
    8. If user.Text = user2 & pass.text = pass2 Then
    9.     GoTo right
    10. Else
    11.     GoTo wrong
    12. End If
    13.  
    14. wrong:
    15. msgbox "Please enter the right username or password!"
    16. goto exit2
    17.  
    18. right:
    19. msgbox "You have entered the right username and password!"
    20.  
    21.  
    22. exit2:
    23. exit sub

    when i try this code, no matter what i type in the two text fields, i always get the message "Please enter the right username and password!" even when I type in bob for username and hi for password.

    please help
    Last edited by Narfy; Apr 21st, 2003 at 05:56 PM.

  2. #2
    New Member
    Join Date
    Apr 2003
    Posts
    2
    If user.Text = user2 & pass.text = pass2 Then

    thats a invalid parameter of the if statement

    replace the & with And

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Utah
    Posts
    397
    nope, still doesn't work....

  4. #4
    Lively Member
    Join Date
    Nov 2002
    Location
    Albacete, Spain
    Posts
    71
    You said:

    VB Code:
    1. user2 = bob
    2. pass2 = hi

    What's that? Do you have two variables called bob and hi? if not, you'd probably want to write:

    VB Code:
    1. user2 = "bob"
    2. pass2 = "hi"

    (If that was the matter, remember the Option Explicit)

    Replace & with And

    And I guess that's all.

    Good luck

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Utah
    Posts
    397
    argggg it still doesn't work.

  6. #6
    Lively Member
    Join Date
    Nov 2002
    Location
    Albacete, Spain
    Posts
    71
    Try this:

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3. Dim user2 As String
    4. Dim pass2 As String
    5.  
    6. user2 = "bob"
    7. pass2 = "hi"
    8.  
    9. If user.Text = user2 And pass.Text = pass2 Then
    10.     MsgBox "You have entered the right username and password!"
    11. Else    
    12.     MsgBox "Please enter the right username or password!"
    13. End If
    14.  
    15. End Sub

    Now, make sure you're typing "bob" in the textbox called "user", and "hi" in the textbox called "hi".
    It should work (I hope so... )

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Utah
    Posts
    397
    thx it worked

  8. #8
    Lively Member
    Join Date
    Nov 2002
    Location
    Albacete, Spain
    Posts
    71
    Sorry, I meant:

    - Type "bob" in the textbox called "user"
    - Type "hi" in the textbox called "pass"

    (I know that this sounds too obvious, but most of the times the mistake comes out because we're wrong with the tests.)

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