|
-
Apr 13th, 2000, 08:05 AM
#1
Thread Starter
Member
Hello, I am having some trouble getting my little cheap password screen to work like I want...Heres what Im trying to get: if the UserName is blank at any time..you get a popup saying theres no username...but if the password is right AND user name has text in it the program opens...heres my code:
Private Sub cmdOK_Click()
If txtUserName = "" Then
MsgBox " Enter A Valid User Name!"
LoginSucceeded = False
txtUserName.SetFocus
End If
If txtPassword = "password" Then
LoginSucceeded = True
Me.Hide
Else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
If LoginSucceeded = True Then
Form1.Visible = True
Form1.Label1.Caption = "User: " & frmLogin.txtUserName & "..Active"
End If
So far all it does on the username popup message but if the password is right it opens anyway...sorry if this is confusing im still new...thanks
-
Apr 13th, 2000, 08:16 AM
#2
Hyperactive Member
The problem is that once you have checked to see if there is no user name you shouldn't then check to see if there is a password.
So try it like this :
Code:
Private Sub cmdOK_Click()
If txtUserName = "" Then
MsgBox " Enter A Valid User Name!"
LoginSucceeded = False
txtUserName.SetFocus
Else
If txtPassword = "password" Then
LoginSucceeded = True
Me.Hide
Else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End If
If LoginSucceeded = True Then
Form1.Visible = True
Form1.Label1.Caption = "User: " & frmLogin.txtUserName & "..Active"
End If
-
Apr 13th, 2000, 08:17 AM
#3
Hyperactive Member
your problem lies with
Code:
If txtPassword = PassWord Then
That's the only condition you have. What you need is,
Code:
"If txtPassWord = PassWord AND txtUserName = "User" Then"
or some other such additional test to make sure that the txtUserName has been entered.
bob
-
Apr 13th, 2000, 08:19 AM
#4
Thread Starter
Member
Ok cool thankz to both of you!
-
Apr 13th, 2000, 08:21 AM
#5
Thread Starter
Member
By the way how come my code looks normal and not ina section like those? (call me dumb ) hahaha thanks again
-
Apr 13th, 2000, 08:27 AM
#6
Hyperactive Member
Have a look at this page :
http://forums.vb-world.net/index.php?action=bbcode
It describes everything you need to know
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
|