Function is a function, sub is a subroutine. Both parameters can be passed, but the function has a return value, but the subroutine does not.
Function can return one by its own name Value, sub needs to define other variables, and return the value by address.
The difference between Sub process and Function process:
1. There is no need to define the return value type when defining the Sub procedure, while the Function procedure generally needs to use the “As data type” to define the return value type of the function.
2. There is no statement to assign a value to the procedure name in the Sub procedure, but there must be a statement to assign a value to the function name in the Function procedure.
3. Calling process: Calling Sub process is different from Function process. The calling Sub procedure is an independent statement, and the calling function procedure is only part of the expression. The Sub procedure is also different from the function in that it does not return a value by name. However, like Function procedures, Sub procedures can also modify the value of any variable passed to them.
4. There are two ways to call the Sub procedure:
The following two statements both call the Sub procedure named MyProc.
Call MyProc (FirstArgument, SecondArgument)
MyProc FirstArgument, SecondArgument
Note that when using Call syntax, the parameters must be in parentheses. If the Call keyword is omitted, the parentheses around the parameter must also be omitted. ———————————————— Copyright statement: This article is the original article of the CSDN blogger “maple_YeZi”, and it follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement for reprinting. . Original link: https://blog.csdn.net/qq_41851370/article/details/85261061