|
-
Oct 9th, 2001, 06:10 PM
#1
Thread Starter
New Member
checking for alpha input
how do I make sure that the user has entered a character contained in the alphabet
-
Oct 9th, 2001, 06:28 PM
#2
Check the character's value against 'A'..'Z' and 'a'..'z'. If it is between one of them, it's alpha.
Z.
-
Oct 9th, 2001, 10:01 PM
#3
Use one of the macros in <ctype.h>
isalpha(char) is the best choice
isnumber(), ispunctuation(), isalmostanyhtingyouwantocheckfor()
- made up the last one.....
edit ctype.h, or go into help and look up either ctype or isalpha
-
Oct 10th, 2001, 06:13 AM
#4
Member
He posted this question in General VB too, so I think he wants a VB answer. Which makes me wonder why he posted in a C++ forum.
-
Oct 10th, 2001, 03:00 PM
#5
Frenzied Member
Just as extra info, you can also use the API. (VB & C++).
IsCharAlpha
IsCharAlphaNumeric
-
Oct 10th, 2001, 04:01 PM
#6
Member
And here are their prototypes (in VB ):
VB Code:
Declare Function IsCharAlpha Lib "user32" Alias "IsCharAlphaA" (ByVal cChar As Byte) As Long
Declare Function IsCharAlphaNumeric Lib "user32" Alias "IsCharAlphaNumericA" (ByVal cChar As Byte) As Long
-
Oct 11th, 2001, 02:21 PM
#7
You don't need API for this (in VB).
Code:
If strFoo Like "[A-z]" Then...
-
Oct 11th, 2001, 03:36 PM
#8
Member
But isn't the Like operator really really really slow?
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
|