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!

Date format but not current date HOW? 1

Status
Not open for further replies.

Svanholm

Programmer
Jul 11, 2007
31
0
0
DK
I am new to VB. Work with VB5 Enterprise.

I think this should be simple, but I cannot figure it out:

How do I create a text-box in which the user can write a random date that is not today's date. And still keep the date format?

Example: User inputs 12122009 and I want textbox to change into: 12-12-2009 or 12:12:09 or 12-12-09 or 12:12:2009.

The change should be instant or at the latest at "lost focus".

All the examples I have found work with the current date.

Any ideas?

All the best
Svanholm

 
>Be warned that the DTPicker control has a reputation for being buggy

It is really not worth using this control if the user is allowed to type in values.
If the user doesn't hit Enter or an arrow after changing a field, but Tabs right away, the Change and Validate events may not fire, and the values will revert back to what they were prior (the Change event fires with a delay - 3-5 seconds - when Tabbing).
Using the Lost focus will not help in this case either (by then, the values have reverted back). There is no .SelStart property, in order to get the current position, so you do not know which values are actually being changed, and therefore the KeyPress is useless for as a work-around.

It looks like the developers created this control with only use with a mouse in mind.
 

DTPicker control:
Just figured out a simple work-around, or correction to the problem I had detailed, that is, if anyone is still interested in using the control.
Otherwise I will just save the time having to explain it.
 
strongm, SBerthold and Vb Sun,

thanks for your kind and wise responses.

I am of course interested in your correctional suggestion, SBerthold, complicated though it be.

I think you guys are right concerning the DTPicker being a mouse-facility. (Have not tested it yet)

I did not notice it since I solely used the mouse, by impulse. I figure that the user will act in the same manner. BUT of course it is better that the stuff works.

As I mentioned, I tend to use Andrjezeks version of MonthView. Or is that also just for mice?

 
<You may not have Replace function available in VB 5

You don't. :)
 
Let me specify: I did not mean that the user necessarily had to be allowed to type in the date himself. It's enough if he can choose it. So I do not think the issues mentioned by SBerthold counts for me.

I tested the DTPicker quite thoroughly today, and so far it seems to cover my needs to full extent.

Some of the trouble, being a newbie, is difficulty in being specific in the right terms.

But it seems that the banal and simple solutions are what I am generally looking for.

So I appreciate all your advanced and clever advice. And it is nice that some of you guys have the ability to put yourself in my newbie position and be "simple-minded" for a while.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top