Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Mask in VB 6

Status
Not open for further replies.

Wallegator

Programmer
Jan 3, 2001
58
0
0
US
I have a VB 6 data entry form. I have a date field and a phone # field. How do I force entry into the form in the format mm/dd/yy for date and 000-000-0000 for phone #?

Thank you in advance.
 
The easiest way would probably be to add the Masked Edit control to the project and place a masked edit control on the form for phone number and one for the date. Look up the "Mask" property in the help for the exact format.

Hope that helps

Daren
 
To get dates (and ensure that they are in the right format) I usually use the Date/Time Picker control. It's in Microsoft Windows Common Controls-2 6.0 SP4. You can set the format that it displays in, and format its Value to get exactly what you want.

That avoids any problems with 2/1/2002 (Jan 2 or Feb 1) etc Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Use the maskEdit control

For a phone# for example

Private Sub maskCaller_GotFocus()

maskCaller.Mask = "(###) ###-####"

End Sub

This will force the user to enter it in the format of
(123)456 - 7890

If you will be reading in from a database you will notice that the mask doesn't occur. Therefore in the propery window for the mask box by format enter the following

\(000\) 000 \- 0000

I used the same thing in a program recently

for dates do like this

Private Sub maskDate_GotFocus()

maskCaller.Mask = "##/##/##"

End Sub

Hope this helps!
eelsar

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top