ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   msgbox (https://www.excelbanter.com/excel-programming/294357-msgbox.html)

Jo[_6_]

msgbox
 
Hi
Why does this not work?
MsgBox("message", vbYesNo, "title")
If I do this it does
a = MsgBox("message", vbYesNo, "title")
Why do I need to assign the result to a variable?
Thanks
Jo

Trevor Shuttleworth

msgbox
 
Jo

just remove the brackets ...

MsgBox "message", vbYesNo, "title"

Regards

Trevor


"Jo" wrote in message
...
Hi
Why does this not work?
MsgBox("message", vbYesNo, "title")
If I do this it does
a = MsgBox("message", vbYesNo, "title")
Why do I need to assign the result to a variable?
Thanks
Jo




Frank Kabel

msgbox
 
Hi
try
MsgBox "message", vbYesNo, "title"

--
Regards
Frank Kabel
Frankfurt, Germany

"Jo" schrieb im Newsbeitrag
...
Hi
Why does this not work?
MsgBox("message", vbYesNo, "title")
If I do this it does
a = MsgBox("message", vbYesNo, "title")
Why do I need to assign the result to a variable?
Thanks
Jo



Bob Phillips[_6_]

msgbox
 
Hi Jo,

You don't have to assign the MsgBox to a variable, but the fact that you
specify Yes and No buttons is giving the user a choice, and so it is
reasonable to assume you are interested in that response.

MsgBox is a function, which means that it returns a result. You can capture
the value returned or ignore it if you want, but the syntax is different
depending upon your choice.

For all Functions, if you want to capture the value, it is

result = Function _Call([arg1[, arge2[, arg3[, ...]]]])

If you don'r want to capture the return value, you omit the brackets

Function _Call [arg1[, arge2[, arg3[, ...]]]]

Thus in your case, either of the following works, although in the second
case you will never know whichj button was pressed

a = MsgBox("message", vbYesNo, "title")

MsgBox "message", vbYesNo, "title"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jo" wrote in message
...
Hi
Why does this not work?
MsgBox("message", vbYesNo, "title")
If I do this it does
a = MsgBox("message", vbYesNo, "title")
Why do I need to assign the result to a variable?
Thanks
Jo





All times are GMT +1. The time now is 08:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com