The VBScript statement Sub allows you to create a section of code that can be reused over and over, called a subroutine. It also allows you to name this section of code and refer to it by name, rather than typing it in multiple times.
Subroutines can optionally have parameters associated with them, but they must complete all their work in the subroutine because they can not return any values back to the portion of the program that called them.
Sub routines start with a declaration of the name and parameters and end with a “End Sub” statement. An example subroutine would look like so:
Sub AddNumbers (x, y)
To call this subroutine from your script you would simply place the following code elsewhere in your script:
AddNumbers 2, 4
(Notice that parenthesis were not used when calling the subroutine.)