Results 1 to 7 of 7

Thread: Easy MsgBox Q

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    Just wondering how i would specify vbCritical and vbCancelRetry together on a message box.

    The and and or keywords didn't work.

  2. #2
    Lively Member
    Join Date
    Jul 1999
    Posts
    99

    Post

    use the "+" sign to join the the two constant values.

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

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    vbCritical + vbCancelRetry

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

  4. #4
    Guest

    Post

    Example:

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

  5. #5
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Post

    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

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    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?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    Thank you all



    ------------------
    Micah Carrick
    http://micah.carrick.com
    [email protected]
    ICQ: 53480225


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width