Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 3rd, 2003, 03:19 PM
gper gper is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 6 gper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old December 3rd, 2003, 05:03 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,194 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 57 m 53 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
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

Reply With Quote
  #3  
Old December 5th, 2003, 10:13 AM
gper gper is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 6 gper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile O.k...ThanX

I forgot that an integer is like a temporarily memory. O.k,...thanX any way...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > what Loop should i use?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT