Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SSN format code

Posted on 2008-10-31
9
422 Views
Last Modified: 2010-04-21
I am trying to write code so that when a customer enters in a SSN it adds the dashes in for them, so it would appear like so. xxx-xxx-xxxx.  

Thanks,

Tyler
0
Comment
Question by:VinnyG3
  • 4
  • 4
9 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 22849847
This is a simple string manipulation, that doesn't require a regular expression:

    Dim input As String = "123456789"
    Dim output As String = input.Insert(3, "-").Insert(6, "-")
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 22849884
Or, if this is VB 6 or VBA...

Debug.Print Format(SSN, "000-00-0000")
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 22849893
Like matthewspatrick said: what programming language are you using ?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:VinnyG3
ID: 22852167
I am using VB express 2005
0
 

Author Comment

by:VinnyG3
ID: 22852212
Also is there a way to do this so that while entering the SSN it adds the dashes. Meaning that I dont have to have an out put before it enters the dashes.

Thanks,

Tyler
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 22856068
The Masked Edit Control is one of the standard components. (Right Mouse on the controls bar and select components) Scroll down in the Components Dialog until you see 'Microsoft Masked Edit Control'.
Click the checkbox next to the name and click 'OK'.

Click on the new control when it showS up in your controls bar and draw the control on the form.

Set the mask property to your pattern examole would be "###-###-####". the # character forces numeric input.
0
 

Author Comment

by:VinnyG3
ID: 22866846
Im not sure on what you are talking about, on where to find the masked edit control.

Thanks,

Tyler
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 22866916
Here is a free .NET control someone built for MaskedEditBox:
http://www.codeproject.com/vb/net/cpflexmaskeditbox.asp

Masked Edit Box in vb.net
http://www.codeproject.com/KB/vb/MaskedTextBox.aspx
0
 

Author Closing Comment

by:VinnyG3
ID: 31512020
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This article will show, step by step, how to integrate R code into a R Sweave document
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question