Groups

    VB.NET Small Problem..

    Hi there,

    I am currently working on a password system for an application I have developed.
    The username: Admin
    The Password: Password
    And after 3 tries the application should close.

    I have this and it works for the password, how would I insert the username too?

    If txt_Password.Text "password" Then
    Select Case Var1
    Case Is MsgBox("The password is incorrect", vbExclamation, "Incorrect Password")
    Var1 = Var1 + 1
    Case Else
    MsgBox("You have entered the wrong password too many times, you are now locked out. Please contact your system administrator. The program will now terminate.", vbCritical, "Locked Out")
    Me.Close()
    End Select
    Else
    MsgBox("Password has been entered correctly.")
    Main_Menu.Show()
    Me.Hide()
    End If


    Any form of help would be really appreciated, thanks.

    7 Comments

    Easiest way is to add "AND txt_Username.text "admin"" to your IF statement and change the user message to "Username or password is incorrect".

    Original Poster

    Spriggan;8711797

    add "AND txt_Username.text "admin"" to your IF statement



    Yeah, I thought that would work too. Tried it before but it wasn't working

    Thanks for that anyways

    Original Poster

    It lets you in by typing the username correctly or typing the password correctly.

    Im trying to get it so that it required both the username and password for entry

    SAVE4IT;8711805

    Yeah, I thought that would work too. Tried it before but it wasn't … Yeah, I thought that would work too. Tried it before but it wasn't working :(Thanks for that anyways



    Check the logic, it needs to be an OR not an AND. You want to stop them if the password OR the username are incorrect not just when they're both wrong :thumbsup:

    Original Poster

    megalomaniac;8711883

    Check the logic, it needs to be an OR not an AND. You want to stop them … Check the logic, it needs to be an OR not an AND. You want to stop them if the password OR the username are incorrect not just when they're both wrong :thumbsup:



    Thanks a million Problem SOLVED.

    Rep given

    Banned

    where's VB1 when you need him. he knows all about the VB Net.

    DJ1;8711913

    where's VB1 when you need him. he knows all about the VB Net.



    I nearly read the title as VB1 = Small Problem.
    I was going to tell the OP not to personally attack people! :thumbsup:
    Post a comment
    Avatar
    @
      Text
      Top Discussions
      1. Seems that Uber will NOT have it's London Licence Renewed by TFL - declarin…2251
      2. I want to talk about the WEATHER no politics no religion19047123
      3. What's the most impressive 4k / UHD film you have seen at home?1217
      4. Just heard this...2 ★★★★★★★★★★★★★★ congrats to all on 392k ★★★★★★★★★★★★★★7767296

      See more discussions