Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic Classic (6 and earlier)
Expertise: Beginner
Dec 16, 2009

A Simple Password-Checking Routine

Developed for a password-reset program, this routine ensures that the user-entered password matches specific password criteria. In this example, the password had to be between 8 and 12 characters long and contain at least one upper case, one lower case, and one numeric character. The order of these didn't matter, as long as there was one of each.

After doing some testing, I settled on the LIKE operator, which (unlike popular assumptions) isn't just for database matches.

If (Text1 Like "*[A-Z]*") And _
   (Text1 Like "*[a-z]*") And _
   (Text1 Like "*[0-9]*") And _
   (Len(Text1) > 7 And Len(Text1) < 13) Then
   MsgBox "Password has correct usage."
Else
   MsgBox "Password must be between 8 and 12 characters, " & _
   "with one upper case letter, a lower case letter, and one number."
End If
Brian Abernathy
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap