|
-
Apr 21st, 2003, 05:31 PM
#1
Thread Starter
Hyperactive Member
why doesn't this work!? (resolved)
VB Code:
Private sub Command1_Click()
Dim user2 as string
Dim pass2 as string
user2 = bob
pass2 = hi
If user.Text = user2 & pass.text = pass2 Then
GoTo right
Else
GoTo wrong
End If
wrong:
msgbox "Please enter the right username or password!"
goto exit2
right:
msgbox "You have entered the right username and password!"
exit2:
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.
-
Apr 21st, 2003, 05:33 PM
#2
New Member
If user.Text = user2 & pass.text = pass2 Then
thats a invalid parameter of the if statement
replace the & with And
-
Apr 21st, 2003, 05:35 PM
#3
Thread Starter
Hyperactive Member
nope, still doesn't work....
-
Apr 21st, 2003, 05:39 PM
#4
Lively Member
You said:
What's that? Do you have two variables called bob and hi? if not, you'd probably want to write:
VB Code:
user2 = "bob"
pass2 = "hi"
(If that was the matter, remember the Option Explicit)
Replace & with And
And I guess that's all.
Good luck
-
Apr 21st, 2003, 05:44 PM
#5
Thread Starter
Hyperactive Member
argggg it still doesn't work.
-
Apr 21st, 2003, 05:51 PM
#6
Lively Member
Try this:
VB Code:
Private Sub Command1_Click()
Dim user2 As String
Dim pass2 As String
user2 = "bob"
pass2 = "hi"
If user.Text = user2 And pass.Text = pass2 Then
MsgBox "You have entered the right username and password!"
Else
MsgBox "Please enter the right username or password!"
End If
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... )
-
Apr 21st, 2003, 05:54 PM
#7
Thread Starter
Hyperactive Member
-
Apr 21st, 2003, 05:56 PM
#8
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|