Intelligent MsgBox

How can I accept the ESCAPE key as a NO on a MsgBox, without designing a form that looks like a msgbox?
SylvaniaAsked:
Who is Participating?
 
caraf_gConnect With a Mentor Commented:
Sylvania,

I'm afraid the VB message box is a very limited beast. It can only do so much and nothing more.

So the only solution is to write your own. I know this is very disappointing, but that's Micro$oft for you.

I'm not going to answer this question since you quite clearly stated that you did not want to design your own form. But in that case you're faced with an impossibility.

There are other solutions that should be acceptable if you are willing to be a little bit more flexible. For example you could slightly modify EDDYKT's solution:

MsgBox "hi", vbYesNo + vbDefaultButton2

But if the box MUST perform exactly the way you want it to, there is no other option, but to create your own message box. In that case, check out this sample project I wrote for the purpose. All the difficult design work to make the form look exactly like a messagebox has been done for you so you just need to modify it so it behaves as required.

The project can be found in http://homepage.eircom.net/~carafa/VBSamples/VBAll/MessageBox.zip 


Good luck!

Pino
0
 
AnswerTheManCommented:
MsgBox "hi", vbYesNoCancel
0
 
SylvaniaAuthor Commented:
Like I stated in my question, I want the NO to be pressed when I press the ESC key.  I didn't think I had to mention the vbYesNo was in use.  I'm tired of using vbYesNoCancel where the NO and the Cancel do exactly the same thing.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
EDDYKTCommented:
MsgBox "hi", vbOKCancel + vbDefaultButton2
0
 
SylvaniaAuthor Commented:
Like I stated in my question, I want the NO to be pressed when I press the ESC key. I now think i must insist the vbYesNo IS in use.
0
 
SylvaniaAuthor Commented:
Thanks Caraf_g... or Pino? :)

That wasn't what I wanted, as we both stated, but there is this conviction in your "voice" that, like a siren's call, force me to accept your comment as an answer, for you have convinced me of what I was suspecting.

Thanks for your source, maybe I'll use it if I feel too lazy to code it myself! ;)

Sylvania
0
 
caraf_gCommented:
Sylvania,

You're a star!

Your 100 points have just elevated me to the dizzy heights of the "genius" level, by bumping my points up to 100049

I salute you and I thank you.
0
 
SylvaniaAuthor Commented:
Glad to have participated in the geniusage of you! ;)
0
 
caraf_gCommented:
;-) PS - caraf_g is short for "Giuseppe Carafa" which is my real name (I have no shame).

Pino is my normal name, which is short for Giuseppino.

Thanks again

Pino
0
All Courses

From novice to tech pro — start learning today.