Help with Visual basic?

gov78

Ha made you Look
OP
Member
Joined
Feb 14, 2007
Messages
727
Trophies
0
Age
33
Location
London
Website
Visit site
XP
371
Country
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

Public Class Form1

Private Sub btnLogon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogon.Click
Dim NextForm As New Form2
If txtUser.Text = "admin" And txtPass.Text = "pass" Then
NextForm.Show()
Me.Hide()
End If
txtUser.Text = ""
txtPass.Text = ""


End Sub
End Class
 

murkurie

Well-Known Member
Member
Joined
Feb 16, 2010
Messages
316
Trophies
0
Age
32
Location
California, Redlands
XP
117
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

while "variable for guesses"
 

evandixon

PMD Researcher
Developer
Joined
May 29, 2009
Messages
1,725
Trophies
1
Website
projectpokemon.org
XP
2,403
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.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • NinStar @ NinStar:
    no, I'm asking which one of them you are using
  • crafthp434 @ crafthp434:
    aroma
  • NinStar @ NinStar:
    in that case, there is no such thing as homebrew launcher for aroma
  • NinStar @ NinStar:
    you have to launch your homebrews directly from the wii u menu
  • NinStar @ NinStar:
    there is a plugin that display them on the wii u menu, pretty sure it is enabled by default
  • crafthp434 @ crafthp434:
    so like it doesnt exist
  • crafthp434 @ crafthp434:
    yeah
    ?
  • NinStar @ NinStar:
    it doesn't exist, at least not for aroma
  • crafthp434 @ crafthp434:
    ohhhhh
  • NinStar @ NinStar:
    on tiramisu you can access it by opening mii maker
  • crafthp434 @ crafthp434:
    okay
  • NinStar @ NinStar:
    I don't have a wii u anymore to test it myself, but if homebrews are not visible on the wii u menu I think you can press L + R + minus to open the plugin menu, there should be an option called "homebrews on wii u menu" or something similar
  • crafthp434 @ crafthp434:
    nope
  • crafthp434 @ crafthp434:
    it is L+dpad down+ select
  • crafthp434 @ crafthp434:
    but homebrew is appearing in the home menu btw
  • NinStar @ NinStar:
    yes, now I remember it
  • NinStar @ NinStar:
    then it is working, I also don't like that they did this but it is the only option you have if you are using aroma
  • crafthp434 @ crafthp434:
    i just didint know the homebrew launcher didint exist in aroma
  • crafthp434 @ crafthp434:
    thanks btw
  • Xdqwerty @ Xdqwerty:
    Im downloading fallout 3 goty edition
    +1
  • BigOnYa @ BigOnYa:
    I'm downloading more ram for my hamster pc
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    New hamster PC, with anal operation and BT connectivity!
    +1
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, How do I make enemies respawn on gdevelop after
    the player dies?
  • Psionic Roshambo @ Psionic Roshambo:
    Carrying a PC or phone is so old school!
    Psionic Roshambo @ Psionic Roshambo: Carrying a PC or phone is so old school!