Friday, April 16, 2010

VB Scripting - Function Call

Previous11121314151617181920Next

What is a Function Call in VB Script?


In continuation with the previous discussion of Functions and Procedures in VB Script, Let us understand what a Function call is and why a Function Call is used.


In order to execute a Function we need to call that function at a point in our script and this is called Function call. The whole Function what we write is called a Function Definition and if a piece of code which is converted into a function will not get executed unless we create a call to the function. So to put in a simple way we need to call the functions which we write in the script other wise it is just occupying some lines of code and makes no sense.

This is a general rule that the Function Definition should happen first and then the Function Call. Why is it so? The answer is that since we know the requirements and know how many variables or in this context arguments we use in the function we should define a function and then write the Function Call because we will use these arguments in the Function Call. A function can have zero or more arguments.

Function call can happen any where in the script. Function definition can happen any where in the script but as per coding standards the Function Calls should be at one place before the Function Definitions and these should also be at one place for maintainability, ease of understanding.

VB Script searches first the function and then goes and Function Definition and executes the function.

Previous11121314151617181920Next

No comments:

Post a Comment