Textbox update every frame?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Page
    New Member
    • Jul 2007
    • 36

    Textbox update every frame?

    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.
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by Matthew Page
    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_Activa te

    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

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      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.

      Comment

      • Matthew Page
        New Member
        • Jul 2007
        • 36

        #4
        Originally posted by Killer42
        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

        Comment

        Working...