String format problem...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've worked with vb6 for many years and moving to dotnet. I'm attempting to
do a custom format for a telephone number but I'm not being very successful.
Any help you can provide would be greatly appreciated.

Code as follows:

Dim strTst As String = "3152527030"

strTst = Format(strTst, "(###) ###-####")

Console.WriteLine(strTst)

I was expecting (315) 252-7030, but instead received (###) ###-####

What am I missing here? Formatting was always so simple.
 
Hi,

Dim strTst As String = "3152527030"

Dim dbl As Double = CType(strTst, Double)

Me.Text = dbl.ToString("(###)###-####")

Ken
 
Back
Top