2
我希望这是一个相对容易的问题,虽然我花了几个小时的网页搜索和使用T & E无济于事。希望有人可以帮助; o)无法读取用户表单中单击按钮的值
我有一个excel模块,显示一个用户窗体获得一些输入数据之前做了大量的处理。在用户窗体的底部有几个命令按钮,分别标记为“OK”和“Cancel”。我需要能够让用户更改选项按钮,然后单击确定或取消退出,我的模块将继续基于是否“取消”被按下我似乎无法找到一种方法来读取按下表单上的取消按钮的布尔结果我99%肯定这是某种公共/私人引用错误,但我还没有赢得足够的经验来弄明白但这里是代码片段:
(从模块1)
Sub ModuleName()
Dim State as Boolean
' Display Parameter box
UserForm2.Show
If UserForm2.ButtonCancel Then
State = True
Else
State = False
End If
End Sub
基于真假来回在取消,我可以驱动程序的其余部分。
(UserForm2代码)
Private Sub ButtonCancel_Click()
BtnCancel = True
Unload Me
End Sub
Private Sub ButtonOK_Click()
BtnCancel = False
Unload Me
End Sub
Private Sub ButtonReset_Click()
'Set the Default Settings
NEAlias.Value = "True"
NoteIgnore.Value = "True"
ABIgnore.Value = "True"
LinkIgnore.Value = "True"
End Sub
Private Sub UserForm_Initialize()
Dim BtnCancel As Boolean
'Add the Text to the options
NEIgnore.Caption = "Ignore"
NoteIgnore.Caption = "Ignore"
ABIgnore.Caption = "Ignore"
LinkIgnore.Caption = "Ignore"
NEAlias.Caption = "Alias Only"
NoteAlias.Caption = "Alias Only"
ABAlias.Caption = "Alias Only"
LinkAlias.Caption = "Alias Only"
NEMove.Caption = "Move and Alias"
NoteMove.Caption = "Move and Alias"
ABMove.Caption = "Move and Alias"
LinkMove.Caption = "Move and Alias"
'Set the Default Settings
NEAlias.Value = "True"
NoteIgnore.Value = "True"
ABIgnore.Value = "True"
LinkIgnore.Value = "True"
End Sub
就是这样。它看起来应该很简单,但我很难过。 TIA寻求帮助!
欢迎来到SO!你可以继续并接受你的答案,以便其他人知道它是如何解决的。 – guitarthrower 2010-03-08 15:54:41