+ Reply to Thread
Results 1 to 3 of 3

Simple MsgBox question

  1. #1
    Gig
    Guest

    Simple MsgBox question

    I'm currently new to and studying VBA and having trouble understanding
    the msgbox function.
    Why is it that sometimes you have to include the arguments in
    parentheses and other times you don't. I've noticed that when just a
    prompt is required, it seems that the parentheses are not required.
    Looked all over and haven't found an answer.
    Thanks,
    Greg


  2. #2
    Bob Phillips
    Guest

    Re: Simple MsgBox question

    If you are just calling MsgBox there is no need for parantheses

    Msgbox myMessage,vbYesNo

    If you are returning the Msgbox result (the button pressed) and testing
    that, parentheses are needed

    If MsgBox(myMessage,vbYesNo) = vbYes Then
    ...

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Gig" <[email protected]> wrote in message
    news:[email protected]...
    > I'm currently new to and studying VBA and having trouble understanding
    > the msgbox function.
    > Why is it that sometimes you have to include the arguments in
    > parentheses and other times you don't. I've noticed that when just a
    > prompt is required, it seems that the parentheses are not required.
    > Looked all over and haven't found an answer.
    > Thanks,
    > Greg
    >




  3. #3
    Tom Ogilvy
    Guest

    Re: Simple MsgBox question

    Just to add, that is a convention/the syntax for all functions and
    subprocedures, not just for message boxes.

    --
    Regards,
    Tom Ogilvy


    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    > If you are just calling MsgBox there is no need for parantheses
    >
    > Msgbox myMessage,vbYesNo
    >
    > If you are returning the Msgbox result (the button pressed) and testing
    > that, parentheses are needed
    >
    > If MsgBox(myMessage,vbYesNo) = vbYes Then
    > ...
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (replace somewhere in email address with gmail if mailing direct)
    >
    > "Gig" <[email protected]> wrote in message
    > news:[email protected]...
    >> I'm currently new to and studying VBA and having trouble understanding
    >> the msgbox function.
    >> Why is it that sometimes you have to include the arguments in
    >> parentheses and other times you don't. I've noticed that when just a
    >> prompt is required, it seems that the parentheses are not required.
    >> Looked all over and haven't found an answer.
    >> Thanks,
    >> Greg
    >>

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1