PDA

Click to See Complete Forum and Search --> : Easy MsgBox Q


MicahCarrick
Jan 23rd, 2000, 10:34 AM
Just wondering how i would specify vbCritical and vbCancelRetry together on a message box.

The and and or keywords didn't work.

Tonio169
Jan 23rd, 2000, 10:40 AM
use the "+" sign to join the the two constant values.

------------------

MartinLiss
Jan 23rd, 2000, 10:40 AM
vbCritical + vbCancelRetry

------------------
Marty
Can you buy an entire chess set in a pawn shop?

Jan 23rd, 2000, 08:35 PM
Example:

call MsgBox("Are you sure you want to remove this record?", vbQuestion + vbYesNo + vbDefaultButton2, "Remove")

DiGiTaIErRoR
Jan 23rd, 2000, 08:56 PM
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

MartinLiss
Jan 23rd, 2000, 10:26 PM
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?

MicahCarrick
Jan 23rd, 2000, 10:32 PM
Thank you all :)



------------------
Micah Carrick
http://micah.carrick.com
micah@carrick.com
ICQ: 53480225