Help with Visual basic?

Discussion in 'General Off-Topic Chat' started by gov78, Nov 24, 2010.

Nov 24, 2010

Help with Visual basic? by gov78 at 4:57 PM (430 Views / 0 Likes) 3 replies

  1. gov78
    OP

    Member gov78 Ha made you Look

    Joined:
    Feb 14, 2007
    Messages:
    728
    Location:
    London
    Country:
    United Kingdom
    Hi guy basically i got a problem, im making a basic login program in vb and i need to implement a loop with the login program. Basically i was wondering if anyone has any idea of what type of loop i need and how i would implement this in to my code. The loop need do count how many times the enter a wrong password some thing like "You entered the password or username wrong you have 2 tries left" and i want it to do it 3 time and if failed close the program. Anyone got any clue of how to do this?

    Thanks in advance

    Here my code currently

    Warning: Spoilers inside!
     
  2. murkurie

    Member murkurie GBAtemp Fan

    Joined:
    Feb 16, 2010
    Messages:
    316
    Location:
    California, Redlands
    Country:
    United States
    I would suggest using a while looping, that's the easiest way I can think of,
    then if its wrong, have another popup come up and say you have this many tries left

    Warning: Spoilers inside!
     
  3. gov78
    OP

    Member gov78 Ha made you Look

    Joined:
    Feb 14, 2007
    Messages:
    728
    Location:
    London
    Country:
    United Kingdom
    thanks for the info bud but thats C++ i belive
     
  4. UniqueGeek

    Member UniqueGeek PMD Researcher

    Joined:
    May 29, 2009
    Messages:
    1,329
    Country:
    United States
    Public Class Form1
    dim _trys as integer=0
    Private Sub btnLogon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogon.Click
    Const MaxTrys as integer = 3
    If txtUser.Text = "admin" And txtPass.Text = "pass" Then
    Dim NextForm As New Form2
    NextForm.Show()
    Me.Hide()
    else
    _trys+=1
    If _tries >= MaxTrys Then
    MessageBox.Show("You have entered an incorrect login or password " & MaxTrys.ToString & " or more times. Program will now close.")
    Me.Close
    Else
    MessageBox.Show("You have entered an incorrect login or password. You have tried " & _trys.ToString & " time(s). You have " & (MaxTrys - _trys).ToString & " more trys left.")
    End If
    End If
    txtUser.Text = ""
    txtPass.Text = ""
    End Sub
    End Class


    See if that works, because I don't think a loop is nessessary.
     

Share This Page