Results 1 to 5 of 5

Thread: IsAlphaNumeric?

  1. #1
    Guest
    Does anybody know a function that can see if a keycode is alphanumeric?
    With the KeyDown-procedure I want something done only when a numeric or alphanumeric key is pressed.
    So I want to eliminate all the function keys, tab, arrows,...
    Or maybe anyone knows a function to see if the key that was hit was a function key?

  2. #2
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Halifax,UK
    Posts
    274
    The easiest way is to check the value of the keycode for values in the range you require.


    Regards

    Chris
    VB6 VS2005

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    if not (IsAlphaNumeric(Chr(Keycode)) and IsNumeric(Chr(Keycode))) then 'neither numeric or alphanumeric
    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.

  4. #4
    Guest
    Thanks for the replies.

    Chrisa_Uk, that's the way i'm gonna do it.
    Kedaman, IsAlphaNumeric isn't a VB-function.

  5. #5
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    ...or if you need only defined chars you can check the input like this:

    Code:
    Dim Temp as String
    
    Temp = "abcdefghijklmnopqrstuvwxyz0123456789,.-"
    
    If InStr( 1, Temp, LCase( Chr( KeyCode ) ) ) > 0 Then
       'Key pressed is one of the defined chars
    Endif

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