excel - VBA 在 InputBox 之后显示 MsgBox
问题描述
输入框后没有弹出消息框。
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
解决方案
更改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
推荐阅读
- javascript - Reactjs:如何从孩子更新父母的状态
- javascript - 有人可以解释我如何在这个例子中正确使用参数吗?
- python - 添加一天列
- java - 如何在 Java 中修复“.class expected”
- c - malloc 在编译时和运行时如何处理?
- sql-server - 涌入 SQL Server 连接
- c - LD_LIBRARY_PATH 对 LibXML.so 不生效
- angular - 如何从 firebase 实时数据库中获取用户列表及其 UID
- divide-and-conquer - 如何使用分治法将十进制数转换为二进制数?
- php - 我尝试更多上传图片,但即使我尝试更多,它也会提供错误