Phone number textbox

1. Member
Join Date
Dec 1969
Posts
52

Phone number textbox

I am taking phone numbers in 1 text box. Is there anyway to make sure that I can make sure the format is:<BR>555.555.5555<BR><BR>even if they enter 555-555-5555 or (555)555-5555 or 5555555555 or any other combination?

2. Senior Member
Join Date
Dec 1969
Posts
1,843

RE: Phone number textbox

I wrote a FormatPhone function that will take all formats and put it in a (555) 555-5555 format. I could be modified to your format. <BR><BR>Function FormatPhone(PhoneNumber, TAPI)<BR> &#039;TAPI is True or False whether you want the num in TAPI formatting<BR> On Error Resume Next<BR> <BR> &#039;Strip any Formatting:<BR> PhoneNumber = Replace(PhoneNumber, " ", "")<BR> PhoneNumber = Replace(PhoneNumber, "-", "")<BR> PhoneNumber = Replace(PhoneNumber, "(", "")<BR> PhoneNumber = Replace(PhoneNumber, ")", "")<BR> PhoneNumber = Replace(PhoneNumber, ".", "")<BR> PhoneNumber = Replace(PhoneNumber, "/", "")<BR> If IsNumeric(Left(PhoneNumber, 1)) = True Then<BR> If CInt(Left(PhoneNumber, 1)) = 1 Then<BR> PhoneNumber = Right(PhoneNumber, 10)<BR> End If<BR> End If<BR> <BR> &#039;Format the Number:<BR> FormatPhone = "(000) 000-0000"<BR> If IsNumeric(PhoneNumber) = True Then<BR> If Len(PhoneNumber) = 7 Then<BR> FormatPhone = Left(PhoneNumber, 3) & "-" & Right(PhoneNumber, 4)<BR> ElseIf Len(PhoneNumber) = 10 And IsNumeric(PhoneNumber) = True Then<BR> FormatPhone = "(" & Left(PhoneNumber, 3) & ") " & Mid(PhoneNumber, 4, 3) & "-" & Right(PhoneNumber, 4)<BR> End If<BR> End If<BR> If TAPI = True Then<BR> FormatPhone = "+1 " & FormatPhone<BR> FormatPhone = Replace(FormatPhone, "-", "")<BR> End If<BR>End Function

3. Member
Join Date
Dec 1969
Posts
52

RE: Phone number textbox

Thanks!!

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•