Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Dynamic text phone format??

    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!

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    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

  • #3
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    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

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips


  •  

    Posting Permissions

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