EDCTECH
asked on
Need help with formating a number
I need to format an 11 digit number like this 999-999-99-999 and display it in a label. The formatting is just for display purposes. The number is stored without the dashes in the database. I've tried using String.Format but haven't had much luck. Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You probably had problem with String.Format becauce you do not know of the backlash trick. When you want to force a specific character in the format, but a backslash in front of it:
String.format("{0:###\-### \-##\-###} ",99999999 999)
String.format("{0:###\-###
ASKER
Thanks! That is what I needed.
Dim strSelectedParcel As String = String.Format("{0}-{1}-{2} -{3}", _
btnTemp.Text.Substring(0, 3), _
btnTemp.Text.Substring(3, 3), _
btnTemp.Text.Substring(6, 2), _
btnTemp.Text.Substring(8, 3))
Dim strSelectedParcel As String = String.Format("{0}-{1}-{2}
btnTemp.Text.Substring(0, 3), _
btnTemp.Text.Substring(3, 3), _
btnTemp.Text.Substring(6, 2), _
btnTemp.Text.Substring(8, 3))
abc-def-gh-ijk -> s1,s2,s3,s4
use the string.mid function (in vb)
http://msdn.microsoft.com/en-us/library/aa903372(VS.71).aspx
then use string.format on those, adding dashes as necc.