Simple MsgBox question

  • Thread starter Thread starter Gig
  • Start date Start date
G

Gig

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
 
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)
 
Just to add, that is a convention/the syntax for all functions and
subprocedures, not just for message boxes.
 

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

Back
Top