4 Replies - 1879 Views - Last Post: 26 March 2013 - 12:33 AM Rate Topic: -----

#1 josh0709  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 20-February 13

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.

many thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Date format in vb6

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

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.

Should give you some pointers to start with.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3176
  • View blog
  • Posts: 10,638
  • Joined: 12-December 12

Re: Date format in vb6

Posted 24 March 2013 - 03:05 PM

There is a LostFocus event but it is preferable to use Leave instead.

MSDN reference
Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 572
  • View blog
  • Posts: 2,985
  • Joined: 19-May 09

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.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3176
  • View blog
  • Posts: 10,638
  • Joined: 12-December 12

Re: Date format in vb6

Posted 26 March 2013 - 12:33 AM

View PostBobRodes, on 26 March 2013 - 04:00 AM, said:

Andrew! There isn't a Leave event in VB6. You're posting .Net reference material.

Oops, sorry! I was thinking of the Exit event (for VBA) and drifted to .NET :whatsthat:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1