Solved

SSN format code

Posted on 2008-10-31
9
426 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
[X]
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
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

691 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