#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Msgbox Help

I have noticed for some time that when I start to enter a message box, I get
help popping up that has syntax similar to this:

msgbox(prompt:="Hello World!",buttons as VbMsgBoxStyle=vbokonly)

But I don't have the syntax right as it won't compile. What is wrong?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Msgbox Help

Leave the brackets out if you don't expect a return value?

"Mike H." wrote:

I have noticed for some time that when I start to enter a message box, I get
help popping up that has syntax similar to this:

msgbox(prompt:="Hello World!",buttons as VbMsgBoxStyle=vbokonly)

But I don't have the syntax right as it won't compile. What is wrong?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Msgbox Help

I would just use:

msgbox "Hello World",vbokonly,"My Title"


"Mike H." wrote:

I have noticed for some time that when I start to enter a message box, I get
help popping up that has syntax similar to this:

msgbox(prompt:="Hello World!",buttons as VbMsgBoxStyle=vbokonly)

But I don't have the syntax right as it won't compile. What is wrong?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Msgbox Help

After I posted this I realized I didn't do that part, but even:
let tmp=msgbox(prompt:="Hello World!",buttons as VbMsgBoxStyle=vbokonly)
will not compile....

"Sam Wilson" wrote:

Leave the brackets out if you don't expect a return value?

"Mike H." wrote:

I have noticed for some time that when I start to enter a message box, I get
help popping up that has syntax similar to this:

msgbox(prompt:="Hello World!",buttons as VbMsgBoxStyle=vbokonly)

But I don't have the syntax right as it won't compile. What is wrong?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Msgbox Help


I would just use:

msgbox "Hello World",vbokonly,"My Title"

"Mike H." wrote:

After I posted this I realized I didn't do that part, but even:
let tmp=msgbox(prompt:="Hello World!",buttons as VbMsgBoxStyle=vbokonly)
will not compile....

"Sam Wilson" wrote:

Leave the brackets out if you don't expect a return value?

"Mike H." wrote:

I have noticed for some time that when I start to enter a message box, I get
help popping up that has syntax similar to this:

msgbox(prompt:="Hello World!",buttons as VbMsgBoxStyle=vbokonly)

But I don't have the syntax right as it won't compile. What is wrong?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Msgbox Help

Mike:

The following format uses simple positional arguments:

MsgBox "Hello world!", _
vbInformation + vbOKOnly, _
"Test Message"

The following format uses named arguments. When using named arguments, you
put a colon followed by an equals sign (":=") between the argument name and
the value. Notice that the Buttons argument allows you to sum a bunch of
values together, one to show an icon, another to say what type of button
combination to use, and other values to specify whether the message box is
modal or not. I normally always include an icon, to visually underscore the
importance of the message to the user. In this case, I used the
vbInformation icon, along with the OK button. The "as" that you see is the
VBA editor telling you what type the argument is; it is not included when
you type in your code. In other words, "Buttons" is the parameter,
"VbMsgBoxStyle" is the type of variable that the argument is, so you can
look up "VbMsgBoxStyle" in the Object Browser to see what the valid values
are (or see the MsgBox topic in Excel Help).

MsgBox Prompt:="Hello world!", _
Buttons:=vbInformation + vbOKOnly, _
Title:="Test Message"

Also, if you are not going to use the return value of a function, you
normally do not enclose the arguments in parentheses. If you enclose the
arguments in parentheses, then a compiler error results (the line of code
should be displayed in red). Use the following example, if you are going to
return the value (to see which button the user pressed, if more than one
button is displayed). In this example, leaving the parentheses out will
also result in a compiler error.

Dim varMsgResult As Variant

varMsgResult = MsgBox("Hello world!", _
vbInformation + vbOKOnly, _
"Test Message")

--
Regards,
Bill Renaud



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Msgbox Help

Correction:

The final example probably should have been:

Dim MsgResult As VbMsgBoxResult

MsgResult = MsgBox("Hello world!", _
vbInformation + vbOKOnly, _
"Test Message")

.... as the MsgBox function returns an enum type of result (which can be
several values).

--
Regards,
Bill Renaud



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MsgBox bumper338 Excel Discussion (Misc queries) 1 December 22nd 06 11:32 PM
msgbox ceemo[_40_] Excel Programming 3 October 29th 05 07:20 PM
msgbox Kjeldc Excel Programming 2 August 29th 05 09:54 PM
First MsgBox. Need help RAP Excel Programming 3 August 3rd 05 09:13 PM
MsgBox Dave Peterson[_3_] Excel Programming 0 July 23rd 03 02:11 AM


All times are GMT +1. The time now is 05:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"