By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,045 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Textbox update every frame?

P: 36
In VBA:

Is there a way to get 'tie' a textbox to a variable such that every time the variable updates, the change is reflected in the textbox? If that isn't possible, then it would be acceptable to have a routine run every so often (100 ms, let's say) that would set the textbox to the variable.
Sep 3 '07 #1
Share this Question
Share on Google+
3 Replies


kadghar
Expert 100+
P: 1,295
In VBA:

Is there a way to get 'tie' a textbox to a variable such that every time the variable updates, the change is reflected in the textbox? If that isn't possible, then it would be acceptable to have a routine run every so often (100 ms, let's say) that would set the textbox to the variable.
I dont know if you can "tie" the variable to the text box, i recomend you to add an extra line after each procedure where you set the value to the text box.

I dont know neither how to use Timers in VBA, but you can write this lines in the sub UserForm_Activate

Do
TextBox1.Text = Variable1
DoEvents
Loop

But i dont like this method very much since it could slow down things (just a little bit)
hope this helps
Sep 3 '07 #2

Expert 5K+
P: 8,434
Yes, I seem to recall timers are something of a problem in VBA. I think you have to use the OnTime function to get something equivalent. To quote the remarks in the doco from Excel...
Use Now + TimeValue(time) to schedule something to be run when a specific amount of time (counting from now) has elapsed. Use TimeValue(time) to schedule something to be run a specific time.
Sep 4 '07 #3

P: 36
Yes, I seem to recall timers are something of a problem in VBA. I think you have to use the OnTime function to get something equivalent. To quote the remarks in the doco from Excel...
Use Now + TimeValue(time) to schedule something to be run when a specific amount of time (counting from now) has elapsed. Use TimeValue(time) to schedule something to be run a specific time.
Well... The limit of the ontime function is 1 second, which doesn't really work for me. Googling for the OnTime function, however, led me to the Windows API calls for setting and stopping timers. This works great. Updating 10 times a second appears realtime, yet doesn't tax the system.

Strangely, I can update the UI directly from the callback function that the timer uses, but I can't do it from a callback function from a COM object. Obnoxious.


Thank you for the help!

- Matt
Sep 4 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.