
input mask on text field and split function
Quote:
> Hi,
> on one of my forms, i have a phone number field. it is bound to the
> phone_number field in a table. I want to do 2 things:
> 1. when I save the data to the table, I want to only save numerics,
> not "-" or "."
> 2. when I display the data to the user on the form, I want to display
> it in a mask "xxx-xx-xxxx"
> for #1, I am trying to use the split function but I am having
> problems.
> dim phone1 as string
> phone1 = split (txtPhone1.text, "-")
> that's not working.
> for #2 - not sure what to do.
> need help please
> rafael
Here is a different way of solving your problem...
This type of data entry and verification can be simplified by using 10
DropDownList (ComboBox) boxes with the numbers 0-9 placed into each
one. Now the user can only select a number from each and you don't
have to worry about finding only numbers. Then to store each field
just concatenate the results...
Dim Phone1 as String
'// Assumming you use a Control Array
Phone1 = Cmb(1).Text & Cmb(2).Text & Cmb(3).Text
'// You can also add Static Labels on your form
'// for the "-" dashes if you want.
To answer you original questions.
Try using a Masked Edit box.
#1 Assuming you have all numbers entered. To store this as three
strings...
Use Left to grab the first three characters of the Phone number
strings.
Left(string, length)
Then use
Right(string, length)
to remove the 3 leftmost characters by using right with 7.
Hope that helps