[英]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.