我有两个用户表单。在userform1中,设置“ x”值的脚本为:
Private Sub Combobox1_Change()
x = Combobox1.Value + 2
End Sub
我需要userform2才能使用userform1的textbox1.value = x进行初始化。
我什至不知道从哪里开始。有关如何执行此操作的任何见解?
编辑:我正在尝试下面的userform2代码:
Private Sub UserForm_Initialize()
x = userform1.combobox1.Value
textbox1.Value = x
End Sub
用户窗体初始化良好,但textbox1.Value正常工作。
您可以直接从组合框中获取值。即使不再可见,它也将具有值。
UserForm2:
Private Sub UserForm_Initialize()
Me.TextBox1.Value = UserForm1.ComboBox1.Value + 2
End Sub
我也写过测试它:在模块中:
Sub test()
UserForm1.Show 'I just had a fix value in the combobox for the test
UserForm2.Show
End Sub