I am somewhat new to VB having only used it about a year now. My question is this, when I generate a message box with the vbYes_No option, is there a way to set the focus to the No option rather than the Yes option that it defaults to?
Printable View
I am somewhat new to VB having only used it about a year now. My question is this, when I generate a message box with the vbYes_No option, is there a way to set the focus to the No option rather than the Yes option that it defaults to?
This should work:
Code:SendKeys "{TAB}"
YesNo = MsgBox("Yes/No?", 4 + 32)
Thanks that worked great! And so simple too.
Or use
MsgBox "Yes/No with default as No", vbYesNo + vbDefaultButton2
This will also work:
Sorry Sarun, we posted at the same timeCode:MsgBox "Hello", vbYesNo + vbDefaultButton2, "Hello"
I am using a vbYesNo message box that I really want my users to pay attention to. Thus, I don't want a default button or they will just hit enter and cruise right bye. I have tried setting the default to a non-existent 3rd button but it still stayed at the first button.
1st - 0
2nd - 256
3rd - 512
what I would do would be build a simple form with a label, and two command buttons (yes and no) If you build this right the end user would not notice the difference between the a message box and a form. The trick is you can set up a very small text box (possibly not visible, alothough I don't remember if it can recieve focus if it is not visible) with background and borders set to clear. Then put the focus in this box. That way your end user has to select whether it is yes or no.