– A procedure is also called subprogram since it is a small
program for relatively small problem. – It is enclosed between Sub and End Sub or Function and End Function statements. – When creating a procedure, you must exactly know the task it will perform, if there are data to accept and return, and a name that should express the task effectively. Procedures
– A procedure can either be public or private.
– A public procedure is accessible to all procedures in the module while a private procedure is accessible only to other procedures in the same module. – To create a private procedure, the PRIVATE keyword is used. Example: Private Sub secret() msgbox(“This is a private procedure”) End Sub
Two types of procedures:
1. Sub procedures 2. Function procedures Sub Procedures-performs the task but does not return a value. The code is between Sub and End Sub statements. Format: Sub procedure name(parameter list) declaration and statements End Sub Function procedures
Works similar to Sub procedures, except that it returns a
value to the caller. The code is between Function and End Function. Format: Function FunctionName(parameter list) as Return type
Python Advanced Programming: The Guide to Learn Python Programming. Reference with Exercises and Samples About Dynamical Programming, Multithreading, Multiprocessing, Debugging, Testing and More