VBScript program

VBScript can use two procedures:

  • Subroutine
  • Functional Programming


VBScript subroutine

Subroutine:

  • It is a series of statements, Sub and End Sub statements are encapsulated within
  • Perform some operations, butdoes not return value
  • You can have parameters
Sub mysub()
some statements
End Sub

or

Sub mysub(argument1,argument2)
some statements
End Sub

Examples (only for IE)

Sub mysub()
document.write("I was written by a sub procedure")
End Sub



VBScript function program

Functional Programming

  • Is a series of statements, are encapsulated within the Function and End Function statements
  • Perform certain operations, andreturns a value
  • Parameter called to pass it through the program may have.
  • If there is no argument, it must have empty parentheses ()
  • Through the program name assigned to the function of the way, so that it can return a value
Function myfunction()
some statements
myfunction=some value
End Function

or

Function myfunction(argument1,argument2)
some statements
myfunction=some value
End Function

Examples (only for IE)

function myfunction()
myfunction=Date()
end function



Calling program

This simple function is invoked to calculate two arguments:

Examples (only for IE)

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

document.write(myfunction(5,9))

Function "myfunction" returns the parameters "a" and the parameter "b" and. Here returns 14.

When you call the program, you can use the Call statement, as follows:

Call MyProc(argument)

Alternatively, you can omit the Call statement as follows:

MyProc argument