Welcome to Bucaro TecHelp!

Bucaro TecHelp
HTTPS Encryption not required because no account numbers or
personal information is ever requested or accepted by this site

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

ASP VBScript Function Procedures

A procedure is a block of code that performs a task and can be referenced within the program to perform that task. VBScript has two kinds of procedures: Subs and Functions. The difference between a Sub and a function is that a function returns a value, while a Sub does not.

The purpose of a Function is to create a block of code that can be called by a reference (it's name) and can perform a specific operation on arguments that are passed to it and return the result to the calling code. You might want to place code in a Function in order to organize your program, but usually because you want to perform the same Function multiple times in your program.

Shown below is the structure of a function

Function functionName()
  code statements
  functionName = return value
End Function

A function returns a value by assigning the value to its name.

A function can take parameters as shown below.

Function functionName(parameter1, parameter2)
  code statements
  functionName = return value
End Function

If a function does not accept arguments, then it can perform its operation on, or using, variables that are within its scope. A variable declared outside of any function or sub-procedure has a global scope. A global variable can be accessed by any code, sub-procedure, or function, and its value can be modified anywhere in the program flow.

Shown below is an example of a function

<%
Function addFunction(a, b)
  addFunction = a + b
End Function 

response.write(addFunction(9,6))
%>

This function calculates the sum of two numbers and returns the result.

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Fire HD
[Site User Agreement]  [Advertise on This site]  [Search This Site]  [Contact Form]
Copyrightę2001-2010 Bucaro TecHelp P.O.Box 18952 Fountain Hills, AZ 85269