gettingstarted
[Top] [All Lists]

Single Key entry ( was: masking)

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Single Key entry ( was: masking)
From: Terry Ford <tmford at shaw dot ca>
Date: Thu, 24 Feb 2005 11:32:45 -0800
Delivered-to: gettingstarted at lists dot realsoftware dot com
References: <BAY2-F19542CAC1748759524C202DA640 at phx dot gbl> <a0620071ebe43c5e4d08b at [10 dot 10 dot 13 dot 4]>
If you wish to force the user to enter a "0" before any single number keypress (for the numbers 6 to 9), Joe's solution will work. If, on the other hand, you wish any number in a single keypress to be entered then other steps must be taken. The following code will work. A string property must also be added to remember the first keypress. Let's name it aKey As String.

In a Right aligned editfield (Looks nicer :-) :

Function KeyDown(Key As String) As Boolean
   If me.SelStart=0 then
      aKey=Key
      Return False // This will save the first keypress
   End if

   If me.SelStart=1 and val(aKey+Key) >59 Then
      Beep
Return True // If the number is greater than 59 it will be blocked.
   End If
End Function

This will allow you to Tab, Delete and enter 6 to 9 or 06 to 09 but not allow 60+.

Just an option. :-)

Terry Ford

PS. There's a bug in Windows 2000 and XP that allows the characters x,c and v to be entered in a "##" mask. The workaround here would be to *not* use the mask and simply "LimitText" the editfield to two characters.

<http://www.realsoftware.com/feedback/viewreport.php?reportid=zpmdgzzk>


On 24-Feb-05, at 9:58 AM, Joseph J. Strout wrote:

At 5:38 PM +0000 2/24/05, Lennox Jacob wrote:

One little problem, after inputting the data and it gets accepted, I cannot Tab to the next EditField, or delete.

When in this state, put a breakpoint on the first line of the KeyDown event, then Resume your app, and Step through the code to see what's going on.

You probably just need to make the if-test more specific, i.e., change

  Key >= "6"

to

  Key >= "6" and Key <= "9"

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

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