Just wondering how i would specify vbCritical and vbCancelRetry together on a message box.
The and and or keywords didn't work.
Printable View
Just wondering how i would specify vbCritical and vbCancelRetry together on a message box.
The and and or keywords didn't work.
use the "+" sign to join the the two constant values.
------------------
vbCritical + vbCancelRetry
------------------
Marty
Can you buy an entire chess set in a pawn shop?
Example:
call MsgBox("Are you sure you want to remove this record?", vbQuestion + vbYesNo + vbDefaultButton2, "Remove")
or you can use the numerical way(easiest)
where as:
vbCritical = 16
vbQuestion = 32
vbExclamation = 48
vbInformation = 64
and...
OK/Cancel = 1
Abort/Retry/Ignore = 2
Yes/No/Cancel = 3
Yes/no = 4
Retry/Cancel = 5
then the replies:
OK=1
Cancel=2
Abort=3
Retry=4
Ignore=5
Yes=6
No=7
---
then you just add them i.e. I want vbcritical(16) and vbcancelretry(5) = 21
reply = msgbox("You messed up!",21 ,"Critical Error!")
if reply = 2 then
Msgbox "Fine let your computer die!",16,"Good-Bye!"
else
msgbox "Re-try to install my virus? SURE!",48,"This can be fun..."
end if
Have fun,
------------------
DiGiTaIErRoR
I'm sorry, but using numbers rather than the built-in variables is really a bad idea! When you go back 6 months from now and look at your code, which would be easier to understand of the following?
reply = MsgBox("You messed up!", 21, "Critical Error!")
-or-
reply = MsgBox("You messed up!", vbCritical + vbRetryCancel, "Critical Error!")
6 months from now will you remember what 21 is? I sure wouldn't want to have to maintain a program like that. Also, while it's almost 100% sure they wouldn't do it, MS could change the number that, for example, produces a "critical" message from 16 to some other value. So where the number version above would stop working (or worse yet, stop working correctly), MS would at the same time change the value behind vbCritical and it would be transparent to you and the vbCritical version would have no problem.
------------------
Marty
Can you buy an entire chess set in a pawn shop?
Thank you all :)
------------------
Micah Carrick
http://micah.carrick.com
[email protected]
ICQ: 53480225