MsgBox function in VBA displays a message in a window and waits for click on a button.
Example of using Yes-No Message Box:
Sub MessageBoxExample()
Dim iRet As Integer
Dim strPrompt As String
Dim strTitle As String
' Promt
strPrompt = "Ask Your Question Here, OK?"
' Dialog's Title
strTitle = "My Tite"
'Display MessageBox
iRet = MsgBox(strPrompt, vbYesNo, strTitle)
' Check pressed button
If iRet = vbNo Then
MsgBox "NO!"
Else
MsgBox "Yes!"
End If
End Sub
本文介绍如何在VB中使用MsgBox函数创建一个包含Yes和No按钮的消息框,实现与用户的交互并根据用户选择执行不同的操作。
916

被折叠的 条评论
为什么被折叠?



