No offense, but I wouldn't do it that way at all (filters, that is). Instead, I'd make an EditField subclass that implements a state machine via the KeyDown() event. I'd also make two methods in this class, Unformat(s As String) As String, and Format(s As String) As String. In the GotFocus() event, call Unformat() on the existing text to convert it into a string of only digits. Allow certain characters in the KeyDown() event as discussed above, then call Format() in the LostFocus() event to put the result back into the EditField in a formatted form. This is a lot more powerful and gives you the control over what characters are allowed/not allowed; essentially, you make your own filter to fit a specific purpose. Save the resulting EditField (export the class) subclass somewhere, as you'll probably find yourself using it in future projects! :)

On Nov 4, 2006, at 1:48 AM, Matthew Williamson wrote:

I'd like to use an editField mask so the user can enter a 10 digit phone
number, and have the formatting done automatically, like so:

(###) ###-####

And that works, except that the user must start the phone number with the
"(" character. I would prefer it if the user didn't have to enter the
preceding "("--just the 10 digits themselves. I guess I'm asking if there is any way to prepend a character to the mask output. I didn't see anything in
the LR.

I tried using the "C" switch, to make the "(" optional, but hat didn't quite
work right.

I could validate and reformat the phone number when the user leaves the
editField, but it sure would be nice to handle it automatically.

Any ideas? I think maybe I need some sleep.



-Matt


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

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

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

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

Reply via email to