Search
Sponsors

procedures in VBScript


procedures in VBScript

Procedures

There are two types of procedures in VBScript , Sub procedures or Function procedure . If you do not need to return a value you can use the Sub procedure but if your statements need to return a value then use a Function.

Sub Procedures

a sub procedure is a statement / series of statements that are enclosed by the Sub and End Sub statements
a sub procedure cannot return a value but it can perform certain actions
If you do not have any arguments you use ( )
Can take arguments that are passed to it by a calling procedure

Sub samplesub ( )
collection of statements here
End Sub

Example:

sub message() document.write(”this is a VBScript Sub procedure”) end sub call message()Here is the code for the above example above

This code would go in the <HEAD> section of your page ideally

<script language=”VBScript”>
sub message()
document.write(”this is a VBScript Sub procedure”)
end sub

And to call this sub procedure we would use the following script

<script language=”VBScript”>
call message()
</script>

Function Procedures

a function procedure is a statement / series of statements that are enclosed by the Function and End Function statements
a function procedure can return a value and it can perform certain actions
If you do not have any arguments you use ( ) on their own
Can take arguments that are passed to it by a calling procedure
it can return a value by assigning a value to its name

Function samplefunction(  )
collection of statements here
samplefunction = somevalue
End Function

Example

function message1() message1 = “a sample VBScript function” end function document.write “here is ” & message1() Here is the code for the example aboveThis would go in the <HEAD> section

<script language=”VBScript”>
function message1() message1 = “a sample VBScript function”
end function
</script>

This code would call the function

<script language=”VBScript”> document.write “here is ” & message1() </script>

Related posts:

  1. Conditional Statements Conditional Statements If you want to process a different series...
  2. variables in VBScript variables in VBScript Variables Before you use a variable in...
  3. Creating a Layer Creating a Layer   Murray Johnson Ever been low...
  4. Conditional Statements Conditional Statements If you want to process a different series...
  5. arrays in VBScript arrays in VBScript Arrays What if you want to declare...

Related posts brought to you by Yet Another Related Posts Plugin.

Tags: , , , ,

Leave a Reply

Translate