PDA

View Full Version : SSN Format



av8tordude
02-02-2011, 04:08 PM
I have this code that formats numbers as I type in time-format. Can anyone assist in editing this code so that it formats the number I type in SSN format.

Thank you

Select Case Len(Me.TextBox3)
Case 1
Me.TextBox3 = Format(Me.TextBox3, "00\:00")
Case Is > 1
v = Replace(Me.TextBox3, ":", "")
Me.TextBox3 = Format(Val(v), "00\:00")
Case Else
End Select

mancubus
02-03-2011, 01:29 AM
check this out:
http://www.codeforexcelandoutlook.com/excel-vba/formatting-ssn/

mancubus
02-03-2011, 01:31 AM
and

http://www.ozgrid.com/forum/showthread.php?t=143758&page=1


Private Sub tbSSN_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
With tbSSN .Tag = Format(Val(Application.Substitute(.Text, "-", vbNullString)), "###-##-####")
Cancel = Not (.Tag Like "###-##-####")
If Cancel Then
MsgBox "Not SSAN"
Else
.Text = .Tag
End If
End With
End Sub

macropod
02-03-2011, 05:34 AM
I have this code that formats numbers as I type in time-format. Can anyone assist in editing this code so that it formats the number I type in SSN format.Wouldn't it be better to allow the users to simply enter the required SSN digits, then apply the formatting afterwards?