0 votes
in VBA by Expert (798 points)

Hello everyone

 

In the following code, it is supoosed to get the label caption updated by time 1,2,...5

Sub Test()
    Dim i As Integer

    UserForm1.Show vbModeless
    For i = 1 To 5
        UserForm1.Label1.Caption = "status message " & i
        Application.Wait Now() + TimeValue("00:00:01")
    Next i
    Unload UserForm1
End Sub

But when loading the form, I can just see status message 1 and nothing else till the end

How can this be updated so as to get the status message 2 and status message 3 and so on..

1 Answer

0 votes
by Expert (798 points)
selected by
 
Best answer

I have found a solution using this line after Label1.Caption

UserForm1.Repaint

And I welcome any other solutions if there are any ones.

by Super Expert (2.8k points)
+1

Using Repaint is the appropriate way to do this. I use it often on UserForms with dynamic content. Here are a couple examples:

by Expert (798 points)
+1
Thank you very much Mr. Ryan

Welcome to wellsr Q&A
wellsr Q&A is the VBA and Python programming community that rewards you for learning how to code.

Getting Started
Register
VBA Cheat Sheets (On Sale Now)

Earn free prizes for asking VBA and Python questions and for answering questions asked by others in our community.

Looking for something else? Hire our professional VBA Help, instead.

What makes us different?
Our points system rewards you with a chance for free gifts based on the quality of your questions and answers. All you have to do is post and you could get rewarded, like these members:

ParserMonster $25 Amazon Gift Card
Hightree $10 Amazon Gift Card
Thales1 $10 Amazon Gift Card
runfunke $10 Amazon Gift Card
coolag $10 Amazon Gift Card
Siew Hun $10 Amazon Gift Card

So, why don't you join us? It really is an encouraging way to motivate members in our VBA and Python community.

Register

For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.

...