Text Box Mask

I have a textbox that I want a date to be entered into.  How do I get the textbox to do the date mask "__/__/__"?

Who is Participating?
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
You have a value property that return the selected date in a date format.

You can then use it in select queries like this:
mcn.execute "INSERT INTO Employees(empName, empBirthDate) VALUES ('" & txtName.Text & "', '" & format(dtpicker1.value, "yyyy/mm/dd") &"')"  
In the propeties of your textbox,look in the dataformat. Pick date and you have several possibilities of date formats.
Éric MoreauSenior .Net ConsultantCommented:
The DataFormat properties works if your control is bound.

You have at least 2 easy solutions:
1- Use the Date Time Picker control than comes with VB6 and allow to display a calendar and only accept valid date without any code.

2- Use the Mask Edit Control with the Mask property set to ##/##/##. You will have to ensure yourself that the date inputted by the user is valid.
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
DateTimePicker is generally to prefer
I use 3 text boxes and 2 labels with "/", when length of text1 = 2 then text2 set focus, when lenght of text2 = 2 then text3 setfocus etc.  It works the same as having 1 text box.

textbox1  "/"  textbox2  "/"  textbox3
here is something I uses before you will have to edit it a little bit it the only thing I can think of with out Useing other Controls

'Place into textBox On_Change Event

Private Sub Text1_Change()
 Select Case Len(Text1)
  Case 2
  Text1.SelText = "/"
 Case 4
   Text1.SelText = "/"
  End Select
End Sub

'Just Enter something like 14/2/88
tdoveAuthor Commented:

On the datepicker how does that affect mcn.execute INSERT INTO Employees(empName) VALUE (Text3.Text)?  Is the DT picker stilled considered text3.text...
tdoveAuthor Commented:
Adjusted points from 50 to 75
tdoveAuthor Commented:
Thanks Again Emoreau!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.