VBA Constants
Ratings: (No Ratings Yet)
Loading…
Intrinsic Constants
VBA includes a number of built-in or intrinsic constants whose values are predefined by VBA. The best place to find information about the available intrinsic constants is in the VB object browser or by pressing F2.

Button
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. |
vbCritical | 16 | Display Critical Message icon. |
vbQuestion | 32 | Display Warning Query icon. |
vbExclamation | 48 | Display Warning Message icon. |
vbInformation | 64 | Display Information Message icon. |
Return Value
Constant | Value | Description |
vbOk | 1 | vbOk |
vbCancel | 2 | vbCancel |
vbAbort | 3 | vbAbort |
vbRetry | 4 | vbRetry |
vbIgnore | 5 | vbIgnore |
vbYes | 6 | vbYes |
vbNo | 7 | vbNo |
Sub test() Dim yesANDno As Integer yesANDno = MsgBox("Hello World, are you good?", vbYesNo) 'Display YES or NO button If yesANDno = vbYes Then Debug.Print "Your answer is: " & vbCrLf & "YES or " & yesANDno 'result return value of 6 Else Debug.Print "Your answer is:" & vbCrLf & "NO or " & yesANDno 'result return value of 7 End If End Sub
OUTPUT
Your answer is:NO or 7
Your answer is: YES or 6
Tags: VBA constant