PDA

Click to See Complete Forum and Search --> : Troubles on password program . . . doesn't work after the 4th try ! please help!


struntz
Nov 19th, 1999, 08:38 AM
Hello i am having some problems i tried de-bugging the problem but i am just learning how to debug properly i have found out that the values of Pass and UserName go to "" after like the 4th try it works somtimes and then it stops here is the CODE:

Private Sub Command1_Click()
Dim Pass As String, UserName As String

Pass = txtPass.Text
UserName = txtUser.Text
If UserName = "Cory" And Pass = "hello" Then
MsgBox "PassWord Confirmed", 12, "Thank You"
Load Form1
Form1.Show
frmPass.Visible = False
Else
MsgBox "Incorrect Password", 8, "Please try again"
End If

End Sub


can someone please tell me what i am doing wrong in this code? the password program opens when the program is first ran.. . it comes up and then u must enter a username and then a passsword the text boxes are named:
txtUser 'user name
txtPass 'Password
THanks for your time!


------------------
Cory Sanchez
Young Student
ICQ#: 18640149

johnpc
Nov 19th, 1999, 07:02 PM
This seems to work

Private Sub Command1_Click()
Dim Pass As String, UserName As String

Pass = txtPass
UserName = txtUser

If UserName = "Cory" And Pass = "hello" Then
MsgBox "PassWord Confirmed", 12, "Thank You"

Form1.Show
Unload Me
Else
MsgBox "Incorrect Password", 8, "Please try again"
txtUser = ""
txtPass = ""
End If
End Sub

johnpc
Nov 20th, 1999, 02:28 AM
Notice that I unloaded the password form and set the text boxes to null. By
your not unloading the password form, it remained in memory and this is not
good. Also by not
setting the text in the textboxes to null, their values were maintained in
memory locations that could not be reassigned every so many times you ran
through it.
I hope this helps, and you don't need the Text extension on a textbox, i.e.,
Pass = txtPass as Text is the default for textboxes as caption is the
default for labels,
i.e., Label5.Caption = "Cory" is the same as Label5 = Cory

struntz
Nov 20th, 1999, 11:19 AM
Thanks for your help! :) but why wouldn't my code work? it all seemed to fit in right . . . Pass = txtPass.text why would that stop working after like the 5th try but Pass = txtPass worked?

------------------
Cory Sanchez
Young Student
ICQ#: 18640149

struntz
Nov 20th, 1999, 11:29 AM
Thanks for your help! :) but why wouldn't my code work? it all seemed to fit in right . . . Pass = txtPass.text why would that stop working after like the 5th try but Pass = txtPass worked?

------------------
Cory Sanchez
Young Student
ICQ#: 18640149