How To Get A Date To Advance In A TextBox

M

Minitman

Greetings,

I have a TextBox that needs to display in a date format and a
CommandButton that needs to advance this date by 1 day every time it
is clicked.

The first question is how to get TextBox1 to display a date format
(mmm/dd/yyyy)?

The second question is how to advance this date with a CommandButton
(the button is called NextDateButton)?

Any help would be appreciated.

TIA

-Minitman
 
M

mudraker

You have not said were the text box is on a sheet or a dilaog box


for a sheet

this gives todays date
Sheets(1).TextBox1.Text = Format(Now(), "dd/mm/yyyy")

this adds 1 to the date in the text box
Sheets(1).TextBox1.Text = Format(DateValue(Sheets(1). _
TextBox1.Text) + 1, "dd/mm/yyyy"
 
M

Minitman

Sorry, this TextBox is on a UserForm.

I modified your code thus:

TextBox1.Text = Format(DateValue(TextBox1.Text) + 1, "mmm/dd/yyyy")

And placed it in the code of the "Next" button.

It works very well.

Thank you.

-Minitman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top