label.caption没有更新
我在vba中没有问题。 我是新的vba。 所以请在这件事上帮助我。
我有两个用户表单,如图片。
Userform1
Userform2
下面的代码为userform 1
Private Sub CommandButton1_Click() Me.Hide UserForm2.Show End Sub
下面的代码为userform 2
Private Sub CommandButton1_Click() Me.Hide UserForm1.TextBox1.Value = "" UserForm1.Show End Sub Private Sub UserForm_Initialize() Label2.Caption = UserForm1.TextBox1.Value End Sub
问题是当我返回到用户窗体1并input值到文本框,然后单击去button它redirect到用户2,但不更新label1.caption。
任何人都可以帮助我如何更新标签1 ?????
在你的userform 2上使用Useform_Activate事件。
Private Sub UserForm_Activate() Label2.Caption = UserForm1.TextBox1.Value Me.Repaint End Sub
设置值后使用Me.Repaint,这将强制窗体更新它上的所有内容,并显示该值。