Results 1 to 7 of 7

Thread: Format SSN

  1. #1

    Thread Starter
    Banned
    Join Date
    Mar 2000
    Posts
    7

    Post

    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.

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124

    Post

    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'?


  3. #3

    Thread Starter
    Banned
    Join Date
    Mar 2000
    Posts
    7

    Post 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.

  4. #4

    Thread Starter
    Banned
    Join Date
    Mar 2000
    Posts
    7

    Post Hello?

    Is that specific enough?

  5. #5
    New Member
    Join Date
    Mar 2000
    Posts
    3

    Post 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

  6. #6

    Thread Starter
    Banned
    Join Date
    Mar 2000
    Posts
    7

    Post Thank you!

    Thanks a million, ksurjan! It worked like a charm...

  7. #7
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    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
  •  



Click Here to Expand Forum to Full Width