|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
what Loop should i use?
I'm a beginner in VB so can you help me with this.I have created a simple Password Validation, and i want the user to have at most 3 tries if keys in the invalid password. Do i have to use For/Do loop,and where should i place the loop
Private Sub Command1_Click() Dim I As Integer Dim O As Integer, P As Integer Dim A As String 'Check for blank If txtPass.Text = "" Then MsgBox "Try again", vbOKOnly, "Try" Else 'if it is not blank,do this,Check for correct Pass If txtPass.Text = txtPass.Tag Then MsgBox "U got it", vbExclamation + vbOKOnly, "Bye" Else 'If the Pass is wrong then vbRetryCancel Pops out O = MsgBox("ReTry again", vbRetryCancel, "") If O = vbRetry Then 'when Pressin retry txtPass.Text = "" Else End End If End If End If txtPass.SetFocus End Sub |
|
#2
|
||||
|
||||
|
nah.. you shouldn't need a loop at all. I'm assuming that you'll have a submit button that you will be using to enter the procedure. If so, then you will need either a module or global-level counter variable to determine how many times they've tried. Declare a module-level variable at the top of a form like so
Code:
Dim mintTriedLogons as integer
'...all the rest of your procedures
Private Sub Form_Load()
mintTriedLogons = 0
'all the other processing in Load()
End Sub
Private Sub Command1_Click
'Sub variable declarations
mintTriedLogons = mintTriedLogons + 1
if mintTriedLogons>3 then
GoTo LogOnErr
end if
'Rest of processing if logon is ok
LogOnErr:
'Processing to inform user of situation and prevent logons for period of time
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#3
|
|||
|
|||
|
I forgot that an integer is like a temporarily memory. O.k,...thanX any way...
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > what Loop should i use? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|