Solved

Format user data from a InputBox

Posted on 2007-11-23
7
1,149 Views
Last Modified: 2010-04-21
I have an input box for a user to enter a social security number.  I would like to format the user input to: XX-XX-XXXX

Is this possible?

Thank you.

sUSocSec = InputBox("Please enter full patient Social Security Number:" & vbCrLf & "Format (XX-XX-XXXX)", "Social Security Number")
0
Comment
Question by:thandel
[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
  • 2
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20339760
try this

sUSocSec = Format(InputBox("Please enter full patient Social Security Number:" & vbCrLf & "Format (XX-XX-XXXX)", "Social Security Number"), "##-##-####")
0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 250 total points
ID: 20339762
rather than asking the user to properly format the entry, you should allow the user to enter 9 digits, then verify that what the entered was in fact 9 numeric digits, and if so, then format the result as you need>

ALso, using an Input Box is not a good idea.  You would be better served to design your own form, and use that instead.  But with the Input Box:


Dim strSSN As String
strSSN = ""
Do Until Len(strSSN) = 9 And IsNumeric(strSSN)
    strSSN = InputBox("Please enter full patient Social Security Number:", "Social Security Number")
Loop
 
strSSN = Left(strSSN, 3) & "-" & Mid(strSSN, 4, 2) & "-" & Right(strSSN, 4)
 
 
AW

Open in new window

0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 250 total points
ID: 20339826
you can remove the format instruction from the input box so the user will just enter the numbers



sUSocSec = Format(InputBox("Please enter full patient Social Security Number:", "Social Security Number"), "##-##-####")
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:thandel
ID: 20339876
Hmmm Arthur interestin... however pressing cancel doesn't take the user out of this... how can the cancel button stop the loop?
0
 

Author Comment

by:thandel
ID: 20339879
Opps I added this... let me do more testing.

If strSSN = "" Then GoTo Exit_Err_SubmitCA_Click
0
 

Author Comment

by:thandel
ID: 20339915
Here is what I"m testing with..... so far its working nicely.

        Do Until Len(strSSN) = 9 And IsNumeric(strSSN)
            strSSN = InputBox("Please enter patient Social Security Number" & vbCrLf & _
            "(without dashes)", "Social Security Number")
            If strSSN = "" Then GoTo Exit_Err_SubmitCA_Click
        Loop
        strSSN = Left(strSSN, 3) & "-" & Mid(strSSN, 4, 2) & "-" & Right(strSSN, 4)
        Me.Notes = "Social Security Number: " & strSSN & vbCrLf & vbCrLf & Me.Notes
0
 

Author Closing Comment

by:thandel
ID: 31410676
Thanks, I split the points up a bit as both solutions answered my question.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

763 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