Unwanted characters in a TextBox

L

Luke

I have a TextBox where the user is supposed to enter a SSN and a macro that
will search through records on another spreadsheet in an effort to match the
SSN. Sometimes users enters dashes in the SSN and sometimes they don't.
However, all the SSN's in the records have the dashes in them.

If someone enters a SSN without using dashes (or enters the dashes in the
wrong place), how do I adjust the TextBox value so that it is also a
"###-##-####" value just like the ones in the spreadsheet? Just having it
formatted as a SSN won't work; it actually needs to be "###-##-####".

Thanks all.
 
J

Jacob Skaria

Try

Dim strSSN as String
strSSN = "1234567-89"
'OR
'strSSN = TextBox1.Text
MsgBox Format(Replace(strSSN, "-", ""), "000-00-0000")

If this post helps click Yes
 
L

Luke

Perfect. That did it. Gratuitous thanks.

Jacob Skaria said:
Try

Dim strSSN as String
strSSN = "1234567-89"
'OR
'strSSN = TextBox1.Text
MsgBox Format(Replace(strSSN, "-", ""), "000-00-0000")

If this post helps click Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top