VBScript Procedures

VBScript Procedures :

VBScript has two kinds procedures:
  1. Sub procedure.
  2. Function procedure.

Sub Procedures :

A Sub procedure:
  1. it is some claims, surrounded by the Sub and End Sub statements.
  2. may do measures, but does not return a benefit.
  3. will take arguments.
Sub mysub(argument1,argument2)
  some statements
End Sub

Function Procedures :

A Purpose technique:
  1. it is a series of claims, closed by the Purpose and End Purpose claims.
  2. can do activities and can return a value.
  3. may take fights which are transferred to it by way of a contacting technique.
  4. without fights, should contain an empty pair of parentheses ().
  5. results a value by assigning a value to its title.
Function myfunction(argument1,argument2)
  some statements
  myfunction=some value
End Function

Calling a Procedure :

This simple function procedures is called to calculate the sum of two arguments:

Function myfunction(a,b)
myfunction=a+b
End Function 

document.write(myfunction(5,4))

The function “myfunction” will return the sum of argument “a” and argument “b”. In this case 9.

Leave a Reply

Your email address will not be published. Required fields are marked *