View Full Version : Dynamic text phone format??
12-10-2004, 06:56 PM
On an ASP Details page, I have dynamic text with a company's address, phone and fax numbers. I want the phone and fax numbers to be formatted like (###) ###-#### on the screen. They are entered in MS Access in 10-digits only.
I am using DWMX 2004 and am not a programmer or coder by any means. I create my recordsets in DWMX in simple mode, so if you can help me, please be specific. My field names are MbrMainPhone and MbrFax if that helps.
12-10-2004, 07:02 PM
just enter them as spaces,
then when you pull from the data base use replace function to format the numbers correctly,
number from the db,
PhoneNumber = "555 555 5555"
response.write replace(PhoneNumber, " ","-")
output should be: 555-555-5555
12-11-2004, 06:43 PM
alternatively you could use the Mid() function
Response.Write "(" & Mid(strPhoneNumber, 1, 3) & ") " & Mid(strPhoneNumber, 4, 3) & "-" & Mid(strPhoneNumber, 7, 4)
note, this would need there to definately be 10 digits, so like
1234567890 --> (123) 456-7890
anything else such as spaces should be removed as
123 4567890 --> (123) 45-6789
12-31-2004, 02:16 AM
And here's a function I've used for a xxx-xxx-xxxx phone format where the data stored in the database is usually (but possibly not always) in the format xxxxxxxxxx:
' Purpose: Change Phone without symbols to Phone with symbols.
' Remarks: Example: 1111111111 -> 111-111-1111
' Underlying tables are not consistent and do and don't store the extra symbols.
' Dim var.
' Quick exit if blank.
If IsNull(pvarFld) Or (Len(pvarFld) = 0) Then
PhoneNoSymbolToSymbol = pvarFld
' Set var.
varFld = pvarFld
' Replace each ( with nothing just in case there is something to start with.
varFld = Replace(varFld, "(", "")
' Replace each ) with nothing just in case there is something to start with.
varFld = Replace(varFld, ")", "")
' Replace each space with nothing just in case there is something to start with.
varFld = Replace(varFld, " ", "")
' Replace each dash with nothing just in case there is something to start with.
varFld = Replace(varFld, "-", "")
' Add symbols.
varFld = Left(varFld, 3) & "-" & Mid(varFld, 4, 3) & "-" & Mid(varFld, 7, 100)
' Return val.
PhoneNoSymbolToSymbol = varFld
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.