Excel UserForm MsgBox #5 - OK/Cancel Message Box (VBA)

InAnOffice
InAnOffice
11.6 هزار بار بازدید - 11 سال پیش - Learn how to create OK/Cancel
Learn how to create OK/Cancel Message Box in Excel in VBA (also showing how to get the result (response) from OK/Cancel MsgBox).
The code used in this video:
Sub Button1_Click()

'MsgBox - Buttons
'************************************
'Constant           Value   Description
'vbOKOnly           0       Display OK button only.
'vbOKCancel         1       Display OK and Cancel buttons.
'vbAbortRetryIgnore 2       Display Abort, Retry, and Ignore buttons.
'vbYesNoCancel      3       Display Yes, No, and Cancel buttons.
'vbYesNo            4       Display Yes and No buttons.
'vbRetryCancel      5       Display Retry and Cancel buttons.

'MsgBox - Icons
'************************************
'Constant           Value   Description
'vbCritical         16      Display Critical Message icon.
'vbQuestion         32      Display Warning Query icon.
'vbExclamation      48      Display Warning Message icon.
'vbInformation      64      Display Information Message icon.

'MsgBox - Response Codes
'************************************
'Constant           Value   Description
'vbOK               1       OK
'vbCancel           2       Cancel
'vbAbort            3       Abort
'vbRetry            4       Retry
'vbIgnore           5       Ignore
'vbYes              6       Yes
'vbNo               7       No
'************************************

MsgBox "Test Message", vbOKCancel
MsgBox "Test Message", vbOKCancel, "Message Title"
MsgBox "Test Message", vbOKCancel + vbInformation, "Message Title"
MsgBox "Test Message", vbOKCancel + vbInformation + vbDefaultButton1, "Message Title"

Dim iResponse As Integer
iResponse = MsgBox("Test Message", vbOKCancel + vbInformation + vbDefaultButton1, "Message Title")

Select Case iResponse
   Case vbOK
       MsgBox "OK selected"
   Case vbCancel
       MsgBox "Cancel selected"
End Select
End Sub
11 سال پیش در تاریخ 1392/11/27 منتشر شده است.
11,695 بـار بازدید شده
... بیشتر