Results 1 to 8 of 8

Thread: checking for alpha input

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Location
    MI
    Posts
    7

    checking for alpha input

    how do I make sure that the user has entered a character contained in the alphabet

  2. #2
    Zaei
    Guest
    Check the character's value against 'A'..'Z' and 'a'..'z'. If it is between one of them, it's alpha.

    Z.

  3. #3
    jim mcnamara
    Guest
    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

  4. #4
    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.

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Just as extra info, you can also use the API. (VB & C++).

    IsCharAlpha
    IsCharAlphaNumeric
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  6. #6
    And here are their prototypes (in VB ):

    VB Code:
    1. Declare Function IsCharAlpha Lib "user32" Alias "IsCharAlphaA" (ByVal cChar As Byte) As Long
    2. Declare Function IsCharAlphaNumeric Lib "user32" Alias "IsCharAlphaNumericA" (ByVal cChar As Byte) As Long

  7. #7
    Megatron
    Guest
    You don't need API for this (in VB).
    Code:
    If strFoo Like "[A-z]" Then...

  8. #8
    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
  •  



Click Here to Expand Forum to Full Width