I. Sub-process and its call
A Sub procedure is a set of statements contained between Sub and End Sub, which performs an operation without returning a value.
Sub procedures can use parameters (constants, variables and expressions passed by calling procedures). If there are no parameters, the Sub statement must contain empty parentheses ().
Sub Myproc() msgbox ("hello,world")End Sub
//The following is the Sub process sub myproc (NO 1, mo2) msgbox (no1* NO2) end sub with two parameters.
When calling the Sub procedure, just enter the procedure name and all parameters, and separate the parameters with commas.
Another calling method is to use the call statement. If you use a Call statement, all parameters must be enclosed in parentheses.
//There are two calling methods, myProc2 and 3callmyProc (2 2,3).
Second, the interesting process and its call
Funtion program is a set of vbscript statements contained between fun and end fun. Similar to Sub procedure, but fun procedure can return a value.
Function procedures can use parameters (constants, variables, expressions passed by calling procedures). If the Function procedure has no parameters, the function statement must contain empty parentheses ().
The function procedure returns a value through the function name, which is assigned to the function name in the statement of the procedure. The data type of the return value of fun procedure is always Variant.
Function Myproc(no 1, no2) Myproc = no 1*no2End function
To call a function procedure, the function name must be on the right side of the variable assignment statement or in an expression, for example: vno = myproc (2 2,3 3) msgbox myproc (2 2,3).
The way to pass data to a procedure is to use parameters, which can be any valid variable name. To get data from a procedure, you must use the Funtion procedure. Funtion procedures can return values, and Sub procedures do not return values.