ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How To Get A Date To Advance In A TextBox (https://www.excelbanter.com/excel-programming/314346-how-get-date-advance-textbox.html)

Minitman[_4_]

How To Get A Date To Advance In A TextBox
 
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

mudraker[_317_]

How To Get A Date To Advance In A TextBox
 

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"

--
mudrake
-----------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...nfo&userid=247
View this thread: http://www.excelforum.com/showthread.php?threadid=27140


Minitman[_4_]

How To Get A Date To Advance In A TextBox - Solved
 
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


On Thu, 21 Oct 2004 20:58:55 -0500, mudraker
wrote:


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")




All times are GMT +1. The time now is 12:42 PM.

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