Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

string question

Hi , I need to insert a "-" character into a nine digit number ( a social security number ) . Anyone know the best way to do this ? basically I need to take :
xxxxxxxxx and make it : xxx-xx-xxxx
[198 byte] By [Matrix.net] at [2007-11-11 10:21:03]
# 1 Re: string question
If it's actually a number, you can do this:

Dim SSN As String = Format(123456789, "###-##-####")

If it's a nine-character string (e.g., "123456789"), you can do this:

Dim SSN As String = "123456789"
SSN = SSN.Insert(3, "-")
SSN = SSN.Insert(6, "-")
Phil Weber at 2007-11-11 23:11:59 >
# 2 Re: string question
Thanks Phil , haha I didnt get to read your post quick enough so I ended up doing it a much more troublesome way . I'll keep that in mind for next time.
Matrix.net at 2007-11-11 23:12:59 >