Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi, i cant find any threads relating to this so had to start a new 1.
basically wht i need is a text box tht is preformatted for entry by the user for the date.for example the text box is formatted
,,:,,:,,
or
,,/,,/,,wher the forward slashes or colons are permenantly fixed ther and the cursur moves around thm.
The reason for this is i have a program with a vb frontend and an access database for data store. and i need to make sure tht the date is entered each time in the same format. ty in advance

Why don't you use the Microsoft Calendar control? The user will always have to select a valid date and you can convert the date to be entered in your DB to the DB's requirements. Otherwise you might have to create a new textbox control.
But why would you make life difficult for your users and yourself?

sounds like best idea tbh.
.....how would i do tht *ahem* sorry im still learning vb :p
Also my next task in the program is a simple timetable. wher each day has a listbox and the jobs for tht day are listed.Any ideas of how i might be able to accomplish this. Im using sql to interface my DB, but the thing tht i think cud be hard is reading the date and adding on 7 days to it as the user cycles forward week by week, without making a complex algorithm to it follows so it knows whn the week spreads over a change of month.

The following works with VB 6.0
The DateTimePicker control is part of a group of ActiveX controls that are found in the MSCOMCT2.OCX file.
To add in select:
Project
Components
Check "Microsoft Windows Common Controls-2.6.0"
Select OKDateTimePicker formats: Long date, Short date, Time, and custom
Long date example: Monday, December 15, 2003
Short date example: 12/15/2003
Time example: 10:01:23 PMHere is an example with a DateTimePicker control that has its date incremented by 7 days every time a button is clicked:
Private Sub Add7Button_Click()
CurrentDate = MyDatePicker.Value
NewDate = DateAdd("d", 7, CurrentDate)
MyDatePicker.Value = NewDate
End Sub

Although the Date/Time pickers works well another methed is to use the MaskEdBox. This will force the user to enter the date in a pre-determined format.
Using a mask of ##-???-#### the user will see __-___-___ and will have to enter the date in the format 16-Dec-2004. The hyphens are entered automatically.
The separator can be any of the characters recognised by VB including a space. The date entered can be sent to Access unaltered providing it conforms to the same format as set in Control Panel > Regional Options.
Stuart

Click Project > Componants. Scroll down till you come to Microsoft Masked Edit Control. Tick it and add it to the tool box. Add it to the form like a standard text box. Highlight it and hit F1. It will bering up a help screen showing all the methods, events and properties associated with the Masked Edit control.
Stuart

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |