Format textbox for dates

  • Thread starter Thread starter Lieven Mettepenningen
  • Start date Start date
L

Lieven Mettepenningen

Here's my question:

I have a userform with a few textboxes on it, and I want the textboxes to
display only values of the form dd/mm/yyyy ALL THE TIME. The checking of the
day-, month- and year-values shouldn't happen until I leave the textbox. But
I want to use the keypress-event of the boxes to guarantee the right format
all the time. I've already managed to do this for typing new values, so I
only accept numbers from now on. This all works fine, but if I want to erase
my date, I want to manipulate my textbox so I can erase the numbers, but NOT
the slashes, so that I can't empty the box completely. It should contain
always at least: "//".

Does anyone know the answer to my problem?

Thx,

Lieven
_______________________________________________________________________

Lieven Mettepenningen
Software Designer
mailto:[email protected]

NISUS Software Architects
Antwerpsesteenweg 107, B-2390 Oostmalle
Tel : +32(0)3/312.92.30 Fax : +32(0)3/311.72.90
http://www.nisus.be
 
Hi Lieven

Allow me to disagree with you -being a software designer and all :-). You
should imo let the user enter dates in whichever format she wants and that
the computer can recognize, and make your code validate it and format it
afterwards. I'm in dd-mm country too, and I allow my users enter all kinds
of things into my textboxes, most common are
1. Feb
feb
1.2
1.2-03
1-2-2003
1/3-03
1.2.2003
0102
010203
01022003
-and even
Week 5
Week 5 03

If this idea is of interest then post back and I'll dig up the code for it
from the vault.
 
Harald,

I don't know about Lieven, but I would certainly be interested in having
a look at your code!
 
Back
Top