VBScript Procedures
VBScript Procedures :
VBScript has two kinds procedures:
- Sub procedure.
- Function procedure.
Sub Procedures :
A Sub procedure:
- it is some claims, surrounded by the Sub and End Sub statements.
- may do measures, but does not return a benefit.
- will take arguments.
Sub mysub(argument1,argument2)
some statements
End Sub
Function Procedures :
A Purpose technique:
- it is a series of claims, closed by the Purpose and End Purpose claims.
- can do activities and can return a value.
- may take fights which are transferred to it by way of a contacting technique.
- without fights, should contain an empty pair of parentheses ().
- 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))
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.