Click to See Complete Forum and Search --> : Phone Number string manipulation


Chicago75
November 27th, 2002, 09:47 PM
Help..
I am using the String.format() method and getting the following error...

An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format.

Here is the line of the code causing it using VB.net...

strResult = String.Format("{^\d-\d{3}-\d{3}-\d{4}}", hpformato)

The "hpformato" is Dimmed as String. I don't know why this is not working..Help
Chicago75@evildata.com

Athley
November 28th, 2002, 03:46 AM
Is this OK for your situation?

Dim strResult As String
Dim hpformatostring As String = "84235423427"
Dim hpformato As Long = CType(hpformatostring, Long)
strResult = String.Format("{0:#'-'###'-'###'-'####}", hpformato)
MsgBox(strResult)

/Leyan

Chicago75
November 28th, 2002, 10:08 AM
Thanks... I ended up using something similar...

gpnformat = String.Format("{0:###-###-####}", Decimal.Parse(gpnformat))