Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |