...

View Full Version : Dynamic text phone format??



ConnieM
12-10-2004, 05: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.

Thanks!

angst
12-10-2004, 06:02 PM
just enter them as spaces,
then when you pull from the data base use replace function to format the numbers correctly,

example:

number from the db,
PhoneNumber = "555 555 5555"
response.write replace(PhoneNumber, " ","-")

output should be: 555-555-5555

ghell
12-11-2004, 05:43 PM
alternatively you could use the Mid() function
something like...

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

Bullschmidt
12-31-2004, 01: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:

Function PhoneNoSymbolToSymbol(pvarFld)
' 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.
Dim varFld

' Quick exit if blank.
If IsNull(pvarFld) Or (Len(pvarFld) = 0) Then
PhoneNoSymbolToSymbol = pvarFld
Exit Function
End If

' 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
End Function



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum