VBA多选项对话框输出

VBA multiple option dialog box output

我创建了一个包含多个选项的用户表单,现在我希望用户选择的选项显示在调用用户表单的按钮下方的标签中。I changed the caption in the text box under the button to resemble what should happen

但是我的选项不起作用。我应该将输出保存在一个全局变量中,然后再调用它来更改标签吗?如果是这样,我该怎么做?或者是否可以只调用用户表单中的选择?

我尝试 运行 的代码是调用消息框然后更改文本框,它实际上是一个名为 "labelpage"

的标签
Private Sub CommandButton1_Click()

UserForm1.Show
If UserForm1.OptionButton1 = True Then LabelPage.Caption = "Company Restricted"
If UserForm1.OptionButton2 = True Then LabelPage.Caption = "Strictly Confidential"
If UserForm1.OptionButton2 = True Then LabelPage.Caption = "Public Information (does not need to be marked)"

End Sub

在用户表单代码中,我也为每次单击按钮关闭它们提供了这个。

Private Sub OptionButton1_Click()
    OptionButton1.Value = True
    Unload Me
End Sub

Private Sub OptionButton2_Click()
    OptionButton2.Value = True
    Unload Me
End Sub

Private Sub OptionButton3_Click()
    OptionButton3.Value = True
    Unload Me
End Sub

是只是语法上的一个小错误或类似的错误,还是完全错误?预先感谢您的帮助。

问题是您正在卸载用户窗体,这意味着您无法使用这些控件。解决方案是只隐藏用户窗体:

Private Sub OptionButton1_Click()
    Hide
End Sub

Private Sub OptionButton2_Click()
    Hide
End Sub

Private Sub OptionButton3_Click()
    Hide
End Sub