Date format in vb6

Posted 24 March 2013 - 01:48 PM

I have took over an old gym system which was created in vb6 and i am now in the process of transferring it to vb.net, one of the problems at the minute is that i need to clean up the vb6 code to allow it to function more efficiently. the main problem at the moment is that the access database where members data is stored. in the access database the date is set as date/time so in vb6 text box when u enter a new member if the date entered isnt entered dd/mm/yyyy then you get an error or it doesent enter the data. is there a way of formatting the text box so say on lostfocus option if it is not right then a msgbox is displayed.

Replies To: Date format in vb6

Re: Date format in vb6

Posted 24 March 2013 - 02:48 PM

you could look at using the masked edit control, which will allow you to enter dates in the format stated, or you could look at using the CDate function to validate that a valid date is entered, then use the format function, to format it as you want.

You could use the CausesValidation property, to raise the Validate event when leaving the control and do your check in there.

Re: Date format in vb6

Posted 25 March 2013 - 09:00 PM

Andrew! There isn't a Leave event in VB6. You're posting .Net reference material. Josh, CausesValidation/Validate is the preferred way to go, better for many reasons than the LostFocus event. You might change to the Leave event once you move to VB.Net.