|
-
Aug 26th, 2000, 10:11 PM
#1
Thread Starter
Hyperactive Member
How can i detect if the user has an upper-case letter in the textbox when they hit ok?
-
Aug 26th, 2000, 10:38 PM
#2
Code:
Private Sub Command1_Click()
Dim IsIt As Boolean
For i = 1 To Len(Text1)
If Asc(Mid(Text1, i, 1)) = Asc(UCase(Mid(Text1, i, 1))) Then
IsIt = True
Else
IsIt = False
End If
Next
If IsIt = True Then MsgBox "uppercase"
End Sub
Text1 cant have numbers or it will say there is UpperCase even if it isnt.
-
Aug 27th, 2000, 09:22 AM
#3
Member
Use keypress event of the textbox and get the ASCII value of the letter currently entered.
-
Aug 27th, 2000, 04:42 PM
#4
Hyperactive Member
Ascii Value
I think he meant this:
Code:
If KeyAscii = bla then blabla
Replace bla with the value of the Ascii and blabla with the command you want to give him.
To view the Ascii Value list go to the Help Topics on VB and see under Character Sets.
Then go to See Also and go to the other Character Sets to see part 2 of the list.
I hope I helped.
-
Aug 27th, 2000, 04:55 PM
#5
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) = UCase(Chr(KeyAscii)) Then MsgBox "Uppercase detected!"
End Sub
I hope this helps.
-
Aug 27th, 2000, 06:04 PM
#6
You could also use the Like Statement with the "*[A-Z]*" Pattern, i.e.
Code:
Private Sub Command1_Click()
Caption = IIf(Text1 Like "*[A-Z]*", "Contains Uppercase Chars", "No Uppercase Chars.")
End Sub
-
Aug 27th, 2000, 10:23 PM
#7
I would rather use a Select Case or If...Then, than a IIf statement, it is less code, but I heard IIf is a lot slower than a normal If...Then.
-
Aug 28th, 2000, 02:55 AM
#8
transcendental analytic
Aaron's example should be fast enough but this could be even faster:
Code:
If text1<>lcase(text1) then msgbox "Contains upper case"
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|