Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
By "it does not matter" I implied that there is no compile error when MsgBox
has a single argument wrapped in round brackets and its return value is neither assigned not sunk by CALL. "Chip Pearson" wrote: Strangely, if you have only a single argument within the round brackets, it does not matter whether you are using round brackets or not. It does matter. If you enclose the argument to a Sub in parentheses, VBA evaluates it to its actual value and passes it ByVal instead of ByRef. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "AA2e72E" wrote in message ... First, you should use the named constants i.e. vbOKOnly etc., instead of numeric values as this makes your code more readable. The problem is: If you are not interested in what key users clicked, the arguments of the MsgBox function are NOT included in round brackets. If you have included the arguments in round brackets, the result is not transparently sunk i.e you need to assign the result to a variable e.g resp = MsgBox("Message",vbOkOnly) or use CALL, e.g Call MsgBox("Message",vbOkOnly) Strangely, if you have only a single argument within the round brackets, it does not matter whether you are using round brackets or not. "Phil C" wrote: Hi Guys Please help. I am obviously failing to understand something very basic about MsgBox syntax. I have only previously used this function to give simple messages to the user, and provide a single (default) OK button: E.g. MsgBox "Your time has expired" I want to add more buttons in due course (Yes, No, etc) but, for now, was just trying to customise the title (caption) of the the message box: MsgBox ("Your time has expired",vbOKOnly,"Time expiry notification") produces a compile error ("expected: =") and I can't make sense of the Help associated. I am not including any Help/Context, so have left those options blank I have tried assigning the message and Title as strings Dim Msg As String Dim Title As String Msg = "Your time has expired" Title = "Time expiry notification" MsgBox (Msg, vbOKOnly, Title) but to no avail.. And MsgBox (Msg, vbOKOnly, Title, , ,) just produces another type of 'expected' compile error Thanks, Phil PS. Once I have sorted the syntax, I should be able to use 0 instead of vbOKOnly, 1 for vbOKCancel, etc. Right? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
DSUM Basics | Excel Discussion (Misc queries) | |||
basics? | New Users to Excel | |||
VBA form basics | Excel Programming | |||
Excel VBA basics | Excel Programming | |||
Help with the basics. Starting out. | Excel Programming |