vbaextra

VBA : vbYesNo displays a button with OK and nothing else


Title speaks for itself.

Here is an illustration

enter image description here

and here is the line of code I'm using.

If MsgBox("Are you sure?", vbYesNo) = Yes Then Exit Sub

I'm also using EXTRA! X-treme


Solution

  • I'd have to guess that EXTRA! X-treme (wow! hyperbole much?!) is messing with the vb constants, or at least not respecting them if it is intercepting calls to the MsgBox function.

    vbYesNo should be a constant numeric value of 4.

    Also, instead of comparing the result of MsgBox to Yes, you should probably be comparing it to vbYes (numeric value of 6).

    I think you're using VBA correctly (except for the vbYes part), so this might be an EXTRA! X-treme bug (or under-documented feature).


    Solution

    If MsgBox("Are you sure?", 4) = 6 Then Exit Sub