VB problem

Discussion in 'Software' started by ClaretAlan, Sep 21, 2004.

  1. ClaretAlan

    ClaretAlan Private E-2

    I am having a problem with this code. It is for a password program. When I put Password or "Password" in txtinput.text and press enter it says access denied, but if I change the code to n1="Password" it says access allowed. I think it might actually be putting txtinput.text in n1 rather than what is in txtinput.text. I set n1 as a string. Can anyone help?

    Private Sub enter_click()
    n1 = "txtinput.Text"
    If n1 = "Password" Then
    txtoutput.Text = "Access Allowed"
    Else
    txtoutput.Text = "Access Denied"
    End If
    End Sub
     
  2. GregoryDalton

    GregoryDalton Private E-2

    This line looks suspect to me:

    n1 = "txtinput.Text"

    n1 is a string and you are saying its contents should be 'txtinput.Text'

    You will never be able to get past the password because you are making the same comparison each time, eg :
    is txtinput.Text the same as Password

    Try taking the quotes out there and everything else looks fine!

    Cheers,
    Greg
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds