【问题标题】:VBA display MsgBox after InputBoxInputBox后VBA显示MsgBox
【发布时间】:2021-06-15 15:24:23
【问题描述】:

输入框后没有弹出消息框。

Dim Output As Integer
Dim name As Variant
Output = MsgBox("Are You Interested in taking a short survey with me?", vbYesNo + vbQuestion, "Short Survey")
If Output = vbYes Then
MsgBox "Great! I'll guide you through this"
name = InputBox("First Question, What's your name?")
If name = vbYes Then
MsgBox "Welcome"
Else
End If
Else
MsgBox "Thanks! But you can try again if you change your mind"
End If
End Sub

【问题讨论】:

  • 名字可以是vbYes吗?
  • @Nathan_Sav 只是试图用它来创建一个变量。或者你怎么看?
  • "name" 将是您输入框的结果,您正在使用 msgbox 返回
  • 好的,谢谢!它现在正在工作

标签: excel vba inputbox msgbox


【解决方案1】:

If name = vbYes Then 更改为If name <> "" Then

当您输入一些文本时,变量name 获取该文本,而不是vbYes

Dim Output As Integer
Dim name As Variant
Output = MsgBox("Are You Interested in taking a short survey with me?", vbYesNo + vbQuestion, "Short Survey")
If Output = vbYes Then
  MsgBox "Great! I'll guide you through this"
  name = InputBox("First Question, What's your name?")
  If name <> "" Then
    MsgBox "Welcome"
  End If
Else
  MsgBox "Thanks! But you can try again if you change your mind"
End If

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多