Define a function procedure.

      [Public [Default] | Private ] Function name([arg_List]) 
         Exit Function
      End Function

   Public          Extend the scope of this function to all procedures in the project.

   Public Default  Define a method as the default member of a class
                   (Only for public functions defined within a class.)

   Private         Restrict the scope of this function to procedures within the same module.

   name            The name of the function.
   arg_List        Argument variabless passed to the function, comma separated.
                   By default, each local variable=argument (ByRef)
                   To have each local variable=value of the argument prefix the 
                   argument with 'ByValue'.

   statements      Program code

   expression      The value to return.


Function DemoFunc(Arg1, ByRef Arg2)
    ' Return the two arguments in a single string
    DemoFunc = "First: " & Arg1 & " second: " & Arg2
End Function

'Now call the function above
myDemo = DemoFunc("Hello","World")
wscript.echo myDemo

“The most important thing in an argument, next to being right, is to leave an escape hatch for your opponent, so that he can gracefully swing over to your side without too much apparent loss of face” ~ Sydney J. Harris


Sub - Start a subprocedure
IsMember.vbs - Function to determine group membership
Equivalent in PowerShell: Functions

© Copyright 1999-2015
Some rights reserved