Results 1 to 5 of 5

Thread: Troubles on password program . . . doesn't work after the 4th try ! please help!

  1. #1

    Thread Starter
    Registered User struntz's Avatar
    Join Date
    Aug 1999
    Location
    Brockway,Pa,USA
    Posts
    199

    Post

    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:
    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



  2. #2
    Addicted Member
    Join Date
    Jan 1999
    Posts
    239

    Post

    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


  3. #3
    Addicted Member
    Join Date
    Jan 1999
    Posts
    239

    Post

    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



  4. #4

    Thread Starter
    Registered User struntz's Avatar
    Join Date
    Aug 1999
    Location
    Brockway,Pa,USA
    Posts
    199

    Post

    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



  5. #5

    Thread Starter
    Registered User struntz's Avatar
    Join Date
    Aug 1999
    Location
    Brockway,Pa,USA
    Posts
    199

    Post

    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



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