Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default 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
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
when are [ ] brackets used cmat Excel Worksheet Functions 2 October 21st 08 10:35 PM
Array Brackets {} Steved Excel Worksheet Functions 2 June 14th 07 09:03 AM
help with brackets tombradshawuk Excel Discussion (Misc queries) 3 November 17th 06 10:19 PM
=D6-E6 there are brackets? JillM Charts and Charting in Excel 1 July 21st 06 08:03 PM
Tournament Brackets billymick New Users to Excel 1 January 5th 05 07:00 PM


All times are GMT +1. The time now is 06:47 PM.

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"