Academic Tutorials



English | French | Portugese | German | Italian
Google

Home Source Codes E-Books Downloads Contact Us About Us

VBScript Tutorial
VBScript Introduction
VBScript How to Use
VBScript Variables
VBScript Procedures
VBScript Functions
VBScript Conditions
VBScript Summary

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
AJAX Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PHP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
.NET (dotnet)
Microsoft.Net
XML Web Services
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills


VBScript Procedures
Previous Next

Procedures

In Modern programming procedures are very useful. Dividing our script into procedures helps us to write and maintain programs by segregating related code into smaller, manageable sections. It also helps to reduce the number of lines of code by reuse the same subroutine or function many times in different situations and from different parts of the program.


Sub Procedure:
  • is a sequence of statements, enclosed by the Sub and End Sub statements

  • perform an actions, but does not return a value
  • can take arguments that are passed to it by a calling procedure

  • without arguments, must include an empty set of parentheses ()

For creating the sub procedure, start the section of code with the Sub keyword followed by a name for the sub procedure. It must be followed by an opening and closing parentheses so that it differentiate the name of the sub procedure with any other regular name. Always close the section of the sub procedure with End Sub keyword


Sub DisplayFullName()
Dim FirstName, LastName
Dim FullName

FullName = FirstName & " " & LastName
End Sub

Calling a Procedure

You can call procedure from another procedure, function, or control's event in the body section of an HTML file. To call a simple procedure such as the earlier DisplayFullName, you can just write the name of the sub procedure.

Following example shows the above DisplayFullName sub procedure is called when the user clicks the Detail section of the form:

 

Sub Detailer()
  DisplayFullName
End Sub

Passing an Argument

Sometimes a procedure needs one or more values to work on for carrying an assignment then procedure needs a variable called argument. Another procedure might need more that one argument. The number and types of arguments of a procedure depends on different factors.

If you are writing your own procedure, on the basis of your requirement place arguments You also decide on the type of the argument(s). For a procedure that is taking one argument, in the parentheses of the procedure, write a name for the argument. Below is an example:
 


Sub CalculateArea(Radius)
Dim dblPI
Dim dblArea
dblPI = 3.14159
dblArea = Radius * Radius * dblPI
End Sub

To Call an Argumentative Procedure

There are various ways you call a sub procedure. As we saw already, if a sub procedure doesn't take an argument, you just write its name. If a sub procedure is taking an argument, type the name of the sub procedure followed by the name of the argument. If the sub procedure is taking more than one argument, type the name of the procedure followed by the name of the argument, in the exact order they are passed to the sub procedure, separated by a comma. Below is an example:


Sub Result()
Dim dblHours, dblSalary

CalcAndShowSalary dblHours, dblSalary
End Sub
Sub CalcAndShowSalary(Hours, Salary)
Dim dblResult

dblResult = Hours * Salary
txtResult = dblResult
End Sub


One alternative,to call a sub procedure use the keyword Call.Now in this case, when calling a procedure using Call, you must include the argument(s) between the parentheses. using Call, the above procedure could call the CalcAndShowSalary as follows:


Sub Result()
Dim dblHours As Double
Dim dblSalary As Double

dblHours = txtHours
dblSalary = txtSalary

Call CalcAndShowSalary(dblHours, dblSalary)
End Sub
 



Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previous Next

HTML Quizes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
XML Quizes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizes
JavaScript Quiz
VBScript Quiz
AJAX Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizes
ASP Quiz
PHP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
.NET (dotnet) Quizes
Microsoft.Net Quiz
XML Web Services Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
Multimedia Quizes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Web Building  Quizes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Java Quizes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Programming Langauges Quizes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Soft Skills Quizes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz

Privacy Policy
Copyright © 2003-2008 Vyom Technosoft Pvt. Ltd., All Rights Reserved.