Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
When a message box is displayed you can press Enter on the keyboard to click its default button. The default button will usually be the left-most one of the set:
Connoisseurs of 1980s movies will appreciate the importance of not accidentally choosing Yes when asked this question by a computer...
You can click here to download the file needed for this part of the lesson.
You can click here to download a workbook containing the sample code.
You can set a different button as the default by adding a constant in the Buttons parameter of a message box. In a new workbook, insert a module and create a subroutine called DefaultButton. Add code to display a message box as shown below:
You can add a default button option to the Buttons parameter by adding it to the choice of buttons with the + symbol.
You can combine a choice of default button with a choice of icon:
Specify your choice of buttons, default button and icon in the Buttons parameter.
Running the above code displays a message box which resembles the one shown below:
The only winning move is not to play.
To practise setting a default button on a message box:
Sub IfAtFirst()
MsgBox _
"If at first you don't succeed...", _
vbQuestion + vbAbortRetryIgnore
End Sub
Sub IfAtFirst()
MsgBox _
"If at first you don't succeed...", _
vbQuestion + vbAbortRetryIgnore + vbDefaultButton2
End Sub
Feel free to set one of the other buttons as the default if you have a different attitude to failure.
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.