I want to increase Date until button is released...

hollifd

Board Regular
Joined
Apr 3, 2002
Messages
248
I have a form with a textbox on it. Under the textbox there is a button that says ">" which stands for increase Date. When I press the button, I want to increase the Date in the textbox 1 day at a time until the button is released. How do I do that in VBA?

Thanks,

David
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
I think it would be a combination of MouseDown, Timer, and MouseUp events.
When you experience a mousedown, set the time interval and have the timer event increase the date by a day until the mouseup event, then stop the timer event by setting the timer interval to 0. You would control the speed of the date increase by the value of the timer interval. One second would be a value of 100 or 1000. I always have to test it.
HTH,
 

hollifd

Board Regular
Joined
Apr 3, 2002
Messages
248
Thanks VicRauch,

But while I was waiting for your answer, I noticed the "Auto Repeat" setting for my button. I never noticed that option before but it will repeat the code in the button until the button is released.

Thanks,

David
 

Forum statistics

Threads
1,141,011
Messages
5,703,728
Members
421,312
Latest member
Mooncake1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top