Forum Discussion

Iamvinod's avatar
Occasional Contributor
4 years ago

Format a series of number as a phone number

How Can I Format a Series of Numbers as a Phone Number in vbscript? ex: 4206322623 as (420) 632-2623?
  • BenoitB's avatar
    4 years ago

    Use this very simple VBScript work,

    The trick is to use number as string and thus you can do your format quite easily.


    Function FormatPhone(str)
      FormatPhone = "(" + Left(str, 3) + ") " + Mid(str,4,3) + "-" + Right(str, 4)
    End Function 



    But this is assuming using only US centric fixed format.