realbasic-nug
[Top] [All Lists]

Re: Easy way to permit numbers exclusively?

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Easy way to permit numbers exclusively?
From: Charles Yeomans <yeomans at desuetude dot com>
Date: Wed, 30 Jan 2002 15:18:31 -0500

On Wednesday, January 30, 2002, at 01:45  PM, Paul wrote:

There might be a "better" way to do this...
But what I have done is to add the following to the EditField's KeyDown event:

  if Asc(Key)>47 and Asc(Key)<58 then
    return false
  else
    return true
  end if

This only allows zero through 9 to actually make it into the box.


As written, this will prevent the user from using the Delete and Tab keys. So instead you might use


Return NOT ((Asc(Key)>47 and Asc(Key)<58) or Asc(key) = 8 or Asc(key) = 9)

Charles Yeomans




<Prev in Thread] Current Thread [Next in Thread>