The Function statement creates a function and allows you to list the arguments (if any) which are to be passed into the function.
The major difference between a function and a subroutine, is that a function can return a value. To return a value you use the function name as if it were a already declared variable and simply set the name of the function to the value you want to return. However, you do not not have to assign or Set a return value.
Functions can be declared Private or Public (the default). You can drop out of a function, without exiting the script entirely by using the Exit statement. You can call other functions or subroutines from within a function (nesting). You must end every function with End Function or you will get an error message.
Here is an example of a function and it’s use:
function add(x , y)
add = x+4end Function