Can I customize the Yes/No buttons on a MsgBox?

P

PCLIVE

Can I customize the MsgBox vbYesNo buttons to saw whatever I want? Example:
Instead of the buttons saying "Yes" and "No", am I able to make them say
"One" and "Two"?

n = MsgBox("test", vbYesNo)

Thanks in advance.
Paul


--
 
R

Rick Rothstein

No; however, you can create your own "message box" using a UserForm with a
Label and two CommandButtons on it. Another possibility is to use the
standard MessageBox and customize your question so that Yes/No makes sense
as an answer. For example, your message could read something like this...

You are about to select either "One" or "Two". Would you like to select
"One"?

Personally, I would create my own "message box" using the UserForm.
 
P

PCLIVE

Thanks Rick. I already knew I could do it easily with a UserForm. I just
figured I'd ask about the standard message box since I didn't personally
know of a way. Never hurts to ask.

Thanks,
Paul


--

Rick Rothstein said:
No; however, you can create your own "message box" using a UserForm with a
Label and two CommandButtons on it. Another possibility is to use the
standard MessageBox and customize your question so that Yes/No makes sense
as an answer. For example, your message could read something like this...

You are about to select either "One" or "Two". Would you like to select
"One"?

Personally, I would create my own "message box" using the UserForm.
 
R

Rick Rothstein

I've played with subclassing and hooking back in my compiled VB days, but
they are an absolute pain to develop from scratch... you can expect many
crashes along the way and probably unstable performance if you don't attend
to all the requisite details along the way. Of course, if you have a
reference to fully debugged code, then copy/pasting subclassing and/or
hooking code should probably be alright, but my personal preference is to
avoid subclassing and hooking unless forced into having to use them.
 
J

JLGWhiz

Just an added note, Paul. The standard dialog boxes like InputBox, MsgBox,
SaveAs, etc. are Windows level forms and are not Excel Application specific.
So when you modify one of them, they are modified for every Windows
application and will show up in Outlook, PowerPoint, Word, Access or whatever
other Windows based application you have. As Rick pointed out, it is much
easier to design your own form and write much less and much simpler code to
achieve your end goal.

PCLIVE said:
Thanks Rick. I already knew I could do it easily with a UserForm. I just
figured I'd ask about the standard message box since I didn't personally
know of a way. Never hurts to ask.

Thanks,
Paul


--
 
H

Harald Staff

Absolutely, Rick.
As Mrs Krabappel said to Bart's class, after showing a film about human
reproduction:
"Now that you know how to do it: Don't !"

Best wishes Harald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top