did you know you can say this..
This is what is known as an anonymous function, characterized by function() with no name.
Not only that, but you can pass a function that you define on the fly as an argument to another.
There is a distinction in VBA, y = x(a,b) is clearly a function. However a function can be called as if it were a sub - x a,b is legal, but you can't put in the brackets (unless you say Call x(a,b)).
What's the difference between each of these?
In VBA, the distinction between reading a property and executing a method that is a function is kinda blurry. When you see code like x = r.value you don't really know if this a property or a function, and it doesn't really matter, since VBA knows that in each case, you want the .value property/function to be executed and returned right now.
so consider this js;
All this is a nightmare for converting code - is it a property that now needs to be a method() ? When you see the approach that Google Apps have taken, you will see that items that are intuitively properties, but that are actually methods, have had their names changed- for example getValue() or setValue(), to emphasize that brackets will be needed. This is a good approach, but if your strategy is to minimize code changes by keeping the same names etc, this can be a problem too.
For more like this, see From VBA to Google Apps Script . Why not join our forum,follow the blog or follow me on twitter to ensure you get updates when they are available. Much of the code referred to here is the mcpher library. You can find out how to include it in your project here.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > From VBA to Google Apps Script >