[英]Yes/No Button VBA Excel. The if-else function is not working
我想要实现的是,当您单击“ 是 ”时,应该显示第一个用户表单,如果没有 ,则应显示其他用户:
Private Sub btnDataSecurity_Click()
Question = MsgBox("Is this client specific", vbYesNo)
If vbYes Then
With DBUnilever
.StartUpPosition = 2
.Top = (Application.Height / 2)
.Left = (Application.Width / 2)
.Show
End With
Unload Me
Else
With DataBreach
.StartUpPosition = 2
.Top = (Application.Height / 2)
.Left = (Application.Width / 2)
.Show
End With
End If
Unload Me
End Sub
if-else函数对我不起作用。 我不知道出了什么问题。 有人可以帮我吗?
考虑更换:
If vbYes Then
有:
If Question = vbYes Then
(发布的代码中可能还有其他错误)
正如Gary的学生所说,您应该替换: If vbYes Then
替换为If Question = vbYes Then
。 由于您发布了整个Sub,并且没有Dim
for Question
,因此请确保在使用前声明它(作为Integer
,因为这是MsgBox
的返回类型)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.