Greg Truby
MrExcel MVP
- Joined
- Jun 19, 2002
- Messages
- 10,030
...The msgbox() function supports multiple arguments in the Style parameter...
~hatman
That's what's so amazingly funny about programming in VBA. Here you've developed this amazing app w/ userforms and literally hundreds of controls and yet you just learned something very basic about MsgBox() of all things. (I just learned of the existance of the VBA function MONTHNAME() a couple of weeks ago.) Personally, I'll also add in the vbDefaultButton2 arg on OKCancel boxes when requesting confirmations on a particularly potent action where I cannot or have not developed an "undo".
Just a note to newbies: when using the vbYesNo and testing the response, you must test against the VB constants, not the XL constants. xlYes≠vbYes and xlNo≠vbNo.
<h3>Correct</h3>
Code:
If vbYes = MsgBox("Is Hatman a stud?", vbQuestion + vbYesNo + vbDefaultButton2, "Hi, Paul") Then
<h3>Incorrect</h3>
Code:
If xlYes = MsgBox("Is Hatman a stud?", vbQuestion + vbYesNo + vbDefaultButton2, "Hi, Paul") Then