Redraw a UserForm in VBA

…衆ロ難τιáo~ 提交于 2021-02-11 17:25:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!