我有一个带有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
这里,变量MyVariable运行良好。 但是,在模块中:
Public MyVariable As String
Sub Calculate()
MsgBox (MyVariable) 'the msgbox is empty!
If MyVariable = "ON" Then
Call Sex
End If
End Sub
变量MyVariable始终为空。
答案 0 :(得分:1)
将Public MyVariable As String
从用户窗体移动到模块。然后两个潜艇都能够看到"它