Example - MsgBox Function MsgBox Statement
The example uses MsgBox to display a close without saving message in a dialog box with a Yes button a No button and a Cancel button. The Cancel button is the default response. The MsgBox function returns a value based on the button chosen by the user. The MsgBox statement uses that value to display a message that indicates which button was chosen.
Sub Main
Dim Msg, Style, myTitle, Help, Ctxt, Response, MyString
Msg = "Do you want to continue ? " ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Style = 4 + 16 + 256 ' Define buttons.
myTitle = "MsgBox Demonstration" ' Define Title
Help = "DEMO.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic context.
' Display message.
Response = MsgBox(Msg, Style, myTitle, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
Else ' User chose No.
MyString = "No" ' Perform some action.
End If
End Sub
Related Topics: InputBox, InputBox$ Function