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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make defualt month/day 2 characters.

Status
Not open for further replies.

Groves22

Technical User
Jan 29, 2009
102
US
In an input box, I would like the defualt day/month to be inserted. I need it to be 2 characters long (i.e. 2 = 02). Is it possible?

Here is the code I have now:

Code:
rMonth = InputBox("Please enter month (##):", "What month", Month(Date))

Thanks!
 

Hi,
Code:
rMonth = InputBox("Please enter month (##):", "What month", [/b]Format(Month(Date),"mm")[/b])


Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks for the quick reply!

However, I am getting a Syntax error when I try to run that code. I also tried without the [/b]'s included, and the defualt month came out 01, rather than 02.
 
rMonth = Format(InputBox("Please enter month (##):", "What month", Month(Date)), "00")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks again for another fast reply!!

And thanks PHV... That worked great!
 
I think Skip meant to say
Code:
rMonth = InputBox("Please enter month (##):", "What month", Format(Date, "mm"))
...without the "Month()" wrapping the date.

If you include Month, then you're formatting 02 as a date and displaying only the month. 02 evaluates to 1/2/1900, so the month is January, which will display as "01" for any date.

[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 


Actually what I really meant to "say" was...
Code:
rMonth = InputBox("Please enter month (##):", "What month", [b]Format(Month(Date),"00")[/b])

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top