Call Keyword

If a function is called without specifying a return value then the return value is discarded.


Call AddTwoNumbers(20, 30) 


It is definitely worth understanding how and when parentheses are used and required.
You have to include parentheses when calling functions that return a value.

sReturn = MyFunction("text") 

You have to include parentheses when calling methods that return a value.

Set wbk = Workbooks.Add(Template:="C:\temp\myFile.xlsx") 

You often see this MsgBox syntax, which is bad practice, and very misleading.
When you include a space before an open bracket, the expression gets evaluated first.

MsgBox ("hello world") 

This should be either:



© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext