在模块中使用UserForm中的variables
我有一个CheckBox的用户表单
Public MyVariable As String Private Sub CheckBox1_Click() If CheckBox1.Value = True Then MyVariable = "ON" Else MyVariable = "OFF" End If MsgBox (MyVariable) End Sub
在这里,variablesMyVariable很好地工作。 但是,在模块中:
Public MyVariable As String Sub Calculate() MsgBox (MyVariable) 'the msgbox is empty! If MyVariable = "ON" Then Call Sex End If End Sub
variablesMyVariable总是空的。
将Public MyVariable As String
从用户窗体移动到模块。 那么两个潜艇将能够“看到”它