inStr range

K

kenrav

I need to test the strength of a password by making sure it includes at least
one uppercase character. I'm thinking I'll use inStr. However, will I need
to test for all 26 letters or can I use a range? Thanks.
 
F

fredg

I need to test the strength of a password by making sure it includes at least
one uppercase character. I'm thinking I'll use inStr. However, will I need
to test for all 26 letters or can I use a range? Thanks.

I assume you do not wish to allow the data to be saved if there is NO
Capital letter.

Code the Control's BeforeUpdate event:

Dim intI As Integer
Dim intX As Integer
For intI = 1 To Len([ControlName])
If Asc(Mid([ControlName], intI, 1)) >= 65 And
Asc(Mid([ControlName], intI, 1)) <= 90 Then
intX = intX + 1
End If
Next intI
If intX = 0 Then
MsgBox "There are no capital letters in this field."
Cancel = True
End If
 
K

kenrav

Brilliant! Thanks!

fredg said:
I need to test the strength of a password by making sure it includes at least
one uppercase character. I'm thinking I'll use inStr. However, will I need
to test for all 26 letters or can I use a range? Thanks.

I assume you do not wish to allow the data to be saved if there is NO
Capital letter.

Code the Control's BeforeUpdate event:

Dim intI As Integer
Dim intX As Integer
For intI = 1 To Len([ControlName])
If Asc(Mid([ControlName], intI, 1)) >= 65 And
Asc(Mid([ControlName], intI, 1)) <= 90 Then
intX = intX + 1
End If
Next intI
If intX = 0 Then
MsgBox "There are no capital letters in this field."
Cancel = True
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top