ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date formatting a text box (https://www.excelbanter.com/excel-programming/290857-date-formatting-text-box.html)

JENNA

Date formatting a text box
 
Hi all,

I have a text box in a userform (eg. txtmydate) that I wish to accept
valid date entries only such as: dd/mmm/yyyy.

When the userform is initialised, is there a way to have the text box
display two spaces followed by a '/' and accept only 2 numeric
characters there for the day (eg. 15), and display three spaces
followed by a '/' and accept only 3 text characters there for the
month (eg. Feb), and then accept only 4 numeric characters for the
year (eg. 2004).

So the text box would initial look something like: ' / / '

and a valid entry would be something like 15/Feb/2004.


Thanks again group for your help.

Jen

Tom Ogilvy

Date formatting a text box
 
There is no setting for using a "mask" such as you describe.

You could probably write code in the change event to simulate this, but I
expect it would be very clumsy. Probably easier to tell the use what you
want, what format to use, then use the after update to evaluate their entry
and accept or reject it. Or you could use three separate textboxes to get
the three parts of the date.

--
Regards,
Tom Ogilvy


"JENNA" wrote in message
om...
Hi all,

I have a text box in a userform (eg. txtmydate) that I wish to accept
valid date entries only such as: dd/mmm/yyyy.

When the userform is initialised, is there a way to have the text box
display two spaces followed by a '/' and accept only 2 numeric
characters there for the day (eg. 15), and display three spaces
followed by a '/' and accept only 3 text characters there for the
month (eg. Feb), and then accept only 4 numeric characters for the
year (eg. 2004).

So the text box would initial look something like: ' / / '

and a valid entry would be something like 15/Feb/2004.


Thanks again group for your help.

Jen




JENNA

Date formatting a text box
 
Thanks Tom - at least now I know it can't be done. As you suggested,
I'll probably now go for the three separate textboxes approach.

Regards Jen

(JENNA) wrote in message . com...
Hi all,

I have a text box in a userform (eg. txtmydate) that I wish to accept
valid date entries only such as: dd/mmm/yyyy.

When the userform is initialised, is there a way to have the text box
display two spaces followed by a '/' and accept only 2 numeric
characters there for the day (eg. 15), and display three spaces
followed by a '/' and accept only 3 text characters there for the
month (eg. Feb), and then accept only 4 numeric characters for the
year (eg. 2004).

So the text box would initial look something like: ' / / '

and a valid entry would be something like 15/Feb/2004.


Thanks again group for your help.

Jen


Bob Phillips[_6_]

Date formatting a text box
 
Jen,

I don't think Tom said it can't be done, it certainly can, but he questioned
whether it was worth the effort. The three text box with labels in between
is a far simpler design, will look like a lot of web pages you see every
day, and can have automated tabbing.

I think you have made a wise choice.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"JENNA" wrote in message
om...
Thanks Tom - at least now I know it can't be done. As you suggested,
I'll probably now go for the three separate textboxes approach.

Regards Jen

(JENNA) wrote in message

. com...
Hi all,

I have a text box in a userform (eg. txtmydate) that I wish to accept
valid date entries only such as: dd/mmm/yyyy.

When the userform is initialised, is there a way to have the text box
display two spaces followed by a '/' and accept only 2 numeric
characters there for the day (eg. 15), and display three spaces
followed by a '/' and accept only 3 text characters there for the
month (eg. Feb), and then accept only 4 numeric characters for the
year (eg. 2004).

So the text box would initial look something like: ' / / '

and a valid entry would be something like 15/Feb/2004.


Thanks again group for your help.

Jen





All times are GMT +1. The time now is 01:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com