Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Arguments and brackets
Greetings,
Please help with my VBA education: Sometimes arguments are in brackets, sometimes not. What are the criteria for use of brackets with arguments? TIA David |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Arguments and brackets
Let's learn using examples
First, for Msgbox, if you got values for the second, third (and so on) arguments, you must not use brackets For example MsgBox "Hello World!", vbYesNo, "This is the Title If you add brackets: MsgBox ("Hello World!", vbYesNo, "This is the Title" Excel will return an error However, for Inputbox, because you always need to assign the value to a variable, you always need to use brackets. For example Dim x = InputBox("Are you ok?", vbYesNo,"Yes" Another example. If you have a VBA function called "hello", the syntax is hello(boy, girl When calling the function in a macro procedure, normally, you assign the value to a variable. You always need to use brackets. For example Dim x = hello(1, 2 So, at this point, you may have a idea that, whenever you assign something to a variable, you use brackets. Otherwise, you don't need to use brackets Another example. You got a subroutine with an arguement Private Sub macro1(hh Msgbox h End Su You want to call the above Sub from another Sub Sub calling( macro1 "hello! end su Note here. This example further shows you that in case you're not assigning something to a variable, you don't use brackets ----- David wrote: ---- Greetings Please help with my VBA education Sometimes arguments are in brackets, sometimes not. What are the criteria for use of brackets with arguments TI Davi |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Arguments and brackets
Thanks Edwin for your illuminating response.
I see the brackets are waiting to accept a variable for assignment David |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
when are [ ] brackets used | Excel Worksheet Functions | |||
Array Brackets {} | Excel Worksheet Functions | |||
help with brackets | Excel Discussion (Misc queries) | |||
=D6-E6 there are brackets? | Charts and Charting in Excel | |||
Tournament Brackets | New Users to Excel |