gettingstarted
[Top] [All Lists]

Re: Mask

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: Mask
From: Michael Rebar <mrebar at darkwing dot uoregon dot edu>
Date: Thu, 24 Feb 2005 05:57:59 -0800
Cc:
Delivered-to: gettingstarted at lists dot realsoftware dot com
If ³mask out² means accept only values from 60 to 99 then,
add something like this to the keydown handler of your editfield...

-----------------
Function keyDown (key as string) as boolean
  dim isValid as boolean
  
  // add traps for navigation keys (e.g., return, tab, delete, arrow keys)
 // (these keys should likely be allowed)
 
  isValid=mValidate(me.text+key) //validate existing text plus new key
  if isValid= false then
    me.text=""  // do somethin' fancier; this action isn¹t informative
  else
    me.text=me.text+key
    me.selstart=len(me.text)  // nice cursor
  end if
  return true  
End Function
-----------------

Add a simple validation method like mValidate...

-----------------
Protected Function mValidate(s as string) As boolean
  if (len(s) = 2 and (val(s) > 59 and val(s)<100)) or len(s)=1 then  //s =
single numeral or in range
    return true
  else
    return false
  end if
End Function
-----------------

A (likely) better approach would be to subclass the editfield and
incorporate these behaviors.

HTH,

Michael
_______________________________________________
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>
  • Re: Mask, Michael Rebar <=