Function is a series of statements enclosed by "Function" and "End Function" statements.
The Function performs an activity and returns control to the caller. When it returns control, it also returns a value to the calling code.
You can define a Function in a Class, Structure & Module. By default It is Public. It means, you can call it from anywhere in your application that has access to the class, Structure or Module in which you defined it.
- [Modifiers] Function Name_Of_The_Function [(Arg_List)] As Return_Type
- End Function
- The two Function Modifiers used in this examples are Public & Private. This Modifiers define the scope of the Function.
- Functions with a Private scope can only be called from the source file from where they were defined. In our case it can be called with in the Module. And cannot be called outside the Module.
- Functions with Public scope can be called both outside and inside the Module. Simply we can say as "We can call it any where in the program".
- Default Modifier of the Function is Public.
- By default, the function arguments are passed by reference (In a separate topic, this will be explained in detail).