Features
      Ask DevGuru
      ASP Resources
      Find the Bug
      Knowledge Base
      Links
      Tips of the Week
      Tutorials
  Products
      dgCalendar
      dgCharge New!
      dgChart New!
      dgFileUpload
      dgReport New!
      dgSort
      dgTree
  Site
      Authoring
      Coming Soon
      DevGuru Resume
      Link to Us
      Merchandise
      Sponsorships
      Testimonials
      What's New
  Technologies
      ADO 2.6
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      Transact-SQL Syntax
      VBScript
      WML
      WMLScript
      WSH
      XML DOM

              











STATEMENT:  Function

Implemented in version 1.0
 
Function . . . End Function
 
The Function statement creates a function, assigns a name, and allows you to list the arguments (if any) which are to be passed into the function.
 
The major difference between a function and a subroutine, is that a function can return a value back to where it was called from. The returned value must be assigned to the function name (or Set if it is an object) somewhere inside the function.
 
However, you do not not have to assign or Set a return value.
 
As an option, functions can be declared Private or Public (the default). One option for leaving a Function is to use Exit statements. You can call other functions or subroutines from within a function (nesting). You must end every function with End Function or you will get an error message.
 
Code:
<%
Function aardvark
   Rem you can place all of the code you desire inside a function
End Function
%>

 
Code:
<% Private Function aardvark
   Rem you can place all of the code you desire inside a function
End Function
%>

 
You can list more than one argument in the function.
 
Code:
<%
Function aardvark(myvar1, myvar2, mynumber, myarray)
   Rem you can place all of the code you desire inside a function
End Function
%>


When you call a function that is assigned to a variable and it has one or more arguments, you must enclosed the arguments inside parentheses, otherwise you will get an error.

Code:
<%
returnval = aardvark(myvar1, myvar2, mynumber, myarray)
%>



Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information