Friday, February 29, 2008

VB: Default button to No

Was doing a message box prompt with vbYesNo button in vb6. The default selected button was "YES" and this is useful in certain cases. However, as it was being used to confirm the user action and requires an additional verification before proceeding, it would be preferably to have the button defaulted to "NO".

temp = MsgBox("Confirm shutdown application?", vbQuestion + vbYesNo, "Confirm?")

In order to archieve this, adding a "vbDefaultButton2".

temp = MsgBox("Confirm shutdown application?", vbDefaultButton2 + vbQuestion + vbYesNo, "Confirm?")

Your Ad Here