label.text cannot be update immediately RRS feed

  • Question

  • Hi,


    When my application is running, i want to change the label.text but it will

    not reflect the change in my GUI.



    Label5.Text = "Programming running............."


    But when I put a MsgBox after this, i can see that the change has been updated in the GUI.


    Pls help.


    Thank you and best regards,


    Thursday, June 21, 2007 2:41 AM


  • Without seeing the rest of your code I can only speculate that you have some CPU-intensive task running right after you set the label's text property (e.g. a loop or something similar).


    Try this - right after setting the label's Text property, try inserting one of these lines:


    Code Snippet



      - or -

    Code Snippet



    You can refer to the on-line help for these methods but the first one (Refresh) basically invalidates the control's client area and redraws it.  The second one (DoEvents) will cause any pending Windows messages (e.g. "paint" messages) to be processed.


    Hope this helps.

    Thursday, June 21, 2007 3:19 AM