问题
I have a userform in VBA and I'd like to redraw/update it in the middle of a method.
When the method is called on button click, the function is as below:
UsrForm.Field1.Value = ""
UsrForm.Field2.Value = ""
UsrForm.Label1.Caption = "LOADING..."
/*Processing occurs*/
UsrForm.Field1.Value = val1
UsrForm.Field2.Value = val2
UsrForm.Label1.Caption = "DONE"
However, the update to the form visible only occurs when the method is completed. I get val1, val2, and "DONE" but not the "LOADING..." message. Is there a way to redraw in the middle of the method?
回答1:
Add UsrForm.Repaint
after the loading message:
UsrForm.Field1.Value = ""
UsrForm.Field2.Value = ""
UsrForm.Label1.Caption = "LOADING..."
UsrForm.Repaint
'...
来源:https://stackoverflow.com/questions/23545521/redraw-a-userform-in-vba