Amazon.com: PC Books || Educational Software || Magazines
Amazon: Books-CA || Software-CA || Books-UK || Software-UK

HTML | Javascript | ASP | PHP | VBScript | SQL | Hardware | PC FAQ| WinXP|

Learn to Build, Upgrade, or Repair your Computer Ebook + PC Safety 101 kwwebservice.com Reasonably priced web development & hosting
ASP Basics
Introduction
Variables & Arrays
Sub & Functions
If Statements
Case Statements
Loop Statements
Date Objects
Form Processing
Text File Objects
Database Access
Adding Record
Updating Record
Deleting Record
Virtual Includes
Cookies
Server Variables
Creating Login Page
E-mail
ASP Books @
CA Amazon
UK Amazon
US Amazon

  :: Home
PC Topics
  :: Build A PC
  :: Windows XP
  :: PC Help
Tutorials
  :: HTML
  :: JavaScript
  :: ASP
  :: PHP
  :: VBScript
  :: SQL
Miscellaneous
  :: Code/Scripts
  :: Forum
  :: Links
  :: Contact us
  :: Tell A Friend
  :: In Somali
  ::
Web Articles
  Top Web Hosting
Reviews
  Processing
Online Card Payment Guide
  Domain name
registration & buying guide
  Getting
a website online guide
  Search Engine
submission & optimization tips
Netfirms Web Hosting
Free trial
Quality business correspondence.
Yahoo! Search Marketing

ASP Sub Procedures

Sub procedure is collection of ASP statements that performs a task and executes when it's called on event procedure. Event procedure is any clickable objects or on load event. Sub procedure does not return value but executes its content on call.
The following example uses sub procedure to write information stored in variables:
<%
Sub GetInfo()
  dim name,telephone,fee
  name="Mr. Warsame Guled"
  telephone="555-55555"
  fee=1999
  Response.write("Name: "&name&"<br>")
  Response.write("Telephone: "& telephone &"<br>")
  Response.write("Fee: "& fee &"<br>")
End Sub
GetInfo()
%>
This example simply declares, populates, & writes three variables in the Sub procedure GetInfo. This sub is executed right after the end sub.
You can pass an argument to the sub procedure and provide the value(s) when calling it.

The following example is sub procedure that takes an argument.
<%
Sub circle(r)
  dim pi, area, diameter,circon
  pi=3.14
  area=pi*r^2
  diameter=2*r
  circon=2*pi*r
  response.write("The Circle with radius of "&r&" has the area "&area)
  response.write(" , diameter of " & diameter & " and circonference of "&circon)
End Sub
circle(2) %>

ASP Function Procedures

A Function procedure is a series of VBScript statements enclosed by the Function and End Function statements. A Function procedure is similar to a Sub procedure, but can also return a value. A Function procedure can take arguments (constants, variables, or expressions that are passed to it by a calling procedure).
[msdn.microsoft]

Here is a syntax for none-parameterized function procedure:
<%
function userName()
userName="Maryamna"
end function.
%>
This function remembers user name. You can use this function any number of times in your program and you change it once in here to maintain. Use userName() to call this function. eg; response.write("The usre name is: "& userName()).

Here is a syntax for parameterized function:
<%
Function total(price)
dim tax
tax=price*.09
total=price+tax
end Function
%>
The price value is provided when calling the function. eg; response.write("Total price is: " & total(50)).

The following example is function procedure that takes an argument.
<%
function profit(sellPrice, cost)
  dim pr
  profit=sellPrice-cost
End Function
dim currProfit currProfit=profit(1280,890) response.write("Profit: $"&currProfit)
%>

Variables & Arrays If Statements
Listed @ ConsumerVote.com - The Consumer Rated Web Directory
PC Articles
  Computer Safety
prevent viruses & Spyware