wetmatter nonsense

let's get random 
Filed under

scripting

 

vbs: Sub & Function Procedures

First off there are two types of Procedures. Sub Procedures and Function Procedures. One of the main differences is that a Sub Procedure does not return a value whereas a Function Procedure will. I won't bore you to much unnecessary details...

Syntax (Sub Procedure):

Sub ProcedureName(Arg1,Arg2)
     script statements
End Sub

Syntax (Function Procedure):

Function ProcedureName(Arg1,Arg2)
     script statements
End Function

Let's step through a simple process using both types of procedures (no returning values) stating with a Sub.

SubProc

Now let's move on to a Function Procedure.

FuncProc

So far everything is working the same. Now let's try returning a value, shall we? This time we will start with a Function Procedure.

FuncProc_ReturnedVal

Yeah it worked! Now let's try it with a Sub Procedure.

SubProc_Failed

FAIL! Can't do it, won't do it.

SubProc_Error

Filed under  //   function procedure   scripting   sub procedure   vbs   vbscript   vbsedit  
Posted by Samson Loo 

Comments [0]