Solved

SSN format code

Posted on 2008-10-31
9
423 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

756 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