May 1 2012, 03:35 PM
I forgot how to add a timer to a form. Can someone help me get this to work. thanks
Me.TimerInterval = 1000
Private Sub form_timer()
' Change the button Text color
Select Case True
Case Me.btnPlaceOrder.ForeColor = vbGreen
Me.btnPlaceOrder.ForeColor = vbYellow
Case Me.btnPlaceOrder.ForeColor = vbYellow
Me.btnPlaceOrder.ForeColor = vbRed
Case Me.btnPlaceOrder.ForeColor = vbRed
Me.btnPlaceOrder.ForeColor = vbGreen
May 1 2012, 03:50 PM
Add a timer to an Excel UserForm? Wow, that's a new one on me.... <Googling>
You might want to check out this thread
Hope this helps,
May 1 2012, 04:02 PM
Also new to me, unless you just mean in general having a Wait type of statement? like Application.Wait or Application.OnTime?
I personally have disavowed all my prior pursuits to have vba code "come alive" in pretty much any way (scrolling marquees, movement, color/text changes, etc) unless it's just a one-time, 2 or 3- second ordeal.
Because at the end of the day (unless I"m very mistaken), there isn't any statement you can create that doesn't involve code executing "the WHOLE TIME" (i.e., even while it's waiting).
And I've never met a VBA application yet that can afford to be frozen with code executing just to have things move around. (although seeing MS add a property that could handle it all wouldn't necessarily disappoint me, and I agree that having visually pleasing progress indicators while OTHER code executes behind the scenes is a very worthwhile pursuit).
May 1 2012, 04:13 PM
I got it to work but the code was constantly executing like you said. I had to keep repainting to get the color to change and it looked bad like the form was flashing. Forget it. thanks for the help
May 1 2012, 04:15 PM
No worries. i still think it's an interesting topic because everyone wants an application that has more than one dimension/level (visually) of execution. Could just be I haven't learned it yet. So I"m happy to keep my ears open when the topic arises!
VBA seems to be a programming language built of "one-time routines", as opposed to constantly-running, beneath-the-surface execution, like a person would really wan