format phone number, asp

I needed a quick and dirty function to format a phone number. So i did some googling and some fuckers wanted $10 for one.

Here’s mine, use it at your own risk.

function formatphone(strnum)
if len(strnum) <> 10 then
rtval = strnum
else
rtval = “(” & left(strnum,3) & “) ” & mid(strnum,4,3) & “-” & right(strnum,4)
end if
formatphone = rtval
end function

Leave a Reply