-
My program reads from a DB and does not accept dashes in the Social Security Number. When the user enters dashes in the SSN, how do I format the SSN so that it automatically takes the dashes out so my program does not generate an error?
Thanks for you help.
-
Can you be more specific with this. How is the data stored in the database is it a string like '012345678' or is it stored like '012-34-5678'?
Do you want your program to display the SS# like '012-34-5678'?
-
Sorry...
Currently, the SSN in the database is stored like: 123456789
when the user enters dashes in the SSN, the program generates an error, because the database does not store dashes, only numbers.
What I would like to have happen when someone does enter dashes, is to have the program automatically take the dashes out, so that the SSN can go into the database without dashes.
-
Hello?
-
try this
Pass the ssno as string to the following function , this will remove all the dashes.
Function formatSSN(ssn as string) As long
Dim l As Long
Dim y As String
l = Len(ssn)
For j = 1 To l
If Mid(ssn, j, 1) <> "-" Then
y = y & Mid(ssn, j, 1)
End If
Next
formatSSN = Val(y)
End Function
-
Thank you!
Thanks a million, ksurjan! It worked like a charm...
-
If you're using VB6 then there's a function called Replace() which would do the exact same thing, ie.
Code:
sSSN = Replace(sSSN, "-", "")