|
-
Mar 7th, 2000, 11:49 PM
#1
Thread Starter
Banned
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.
-
Mar 8th, 2000, 12:17 AM
#2
Lively Member
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'?
-
Mar 8th, 2000, 12:27 AM
#3
Thread Starter
Banned
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.
-
Mar 8th, 2000, 01:44 AM
#4
Thread Starter
Banned
Hello?
-
Mar 8th, 2000, 02:03 AM
#5
New Member
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
-
Mar 8th, 2000, 02:31 AM
#6
Thread Starter
Banned
Thank you!
Thanks a million, ksurjan! It worked like a charm...
-
Mar 8th, 2000, 02:45 AM
#7
If you're using VB6 then there's a function called Replace() which would do the exact same thing, ie.
Code:
sSSN = Replace(sSSN, "-", "")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|