- ASP.NET Web Pages - Tutorial
- ASP.NET Web Pages - Adding Razor Code
- ASP.NET Web Pages - Page Layout
- ASP.NET Web Pages - Folders
- ASP.NET Web Pages - Global Pages
- ASP.NET Web Pages - HTML Forms
- ASP.NET Web Pages - Objects
- ASP.NET Web Pages - Files
- ASP.NET Web Pages - Databases
- ASP.NET Web Pages - Helpers
- ASP.NET Web Pages - The WebGrid Helper
- ASP.NET Web Pages - The Chart Helper
- ASP.NET Web Pages - The WebMail Helper
- ASP.NET Web Pages - WebSecurity Object
- ASP.NET Web Pages - Publishing The Website
- ASP.NET Web Pages - Classes
- ASP.NET Razor - Markup
- ASP.NET Razor - C# And VB Code Syntax
- ASP.NET Razor - C# Variables
- ASP.NET Razor - C# Loops And Arrays
- ASP.NET Razor - C# Logic Conditions
- ASP.NET Razor - VB Variables
- ASP.NET Razor - VB Loops And Arrays
- ASP.NET Razor - VB Logic Conditions
- ASP Tutorial
- ASP Syntax
- ASP Variables
- ASP Procedures
- VBScript Conditional Statements
- VBScript Looping
- ASP Forms And User Input
- ASP Cookies
- ASP Session Object
- ASP Application Object
- ASP Including Files
- ASP The Global.asa File
- ASP AJAX
- ASP Sending E-mail With CDOSYS
- VBScript Functions
- VBScript Keywords
- ASP Response Object
- ASP Application Object
- ASP Session Object
- ASP Server Object
- ASP ASPError Object
- ASP FileSystemObject Object
- ASP TextStream Object
- ASP Drive Object
- ASP File Object
- ASP Folder Object
- ASP Dictionary Object
- ASP AdRotator Component
- ASP Browser Capabilities Component
- ASP Content Linking Component
- ASP Content Rotator Component (ASP 3.0)
- ASP Quick Reference
- ADO Introduction
- ADO Database Connection
- ADO Recordset
- ADO Display
- ADO Queries
- ADO Sort
- ADO Add Records
- ADO Update Records
- ADO Delete Records
- ADO Demonstration
- ADO Speed Up With GetString()
- ADO Command Object
- ADO Connection Object
- ADO Error Object
- ADO Field Object
- ADO Parameter Object
- ADO Property Object
- ADO Record Object
- ADO Recordset Object
- ADO Stream Object
- ADO Data Types
ASP Procedures
Procedures
In ASP you can call a JavaScript procedure from a VBScript and vice versa.
The ASP source code can contain procedures and functions:
Example
<html>
<head>
<%
sub vbproc(num1,num2)
response.write(num1*num2)
end sub
%>
</head>
<body>
<p>Result: <%call vbproc(3,4)%></p>
</body>
</html>
Insert the <%@ language="language" %> line above the <html> tag to write the procedure/function in another scripting language:
Example
<!DOCTYPE html>
<html>
<head>
<%
function jsproc(num1,num2)
{
Response.Write(num1*num2)
}
%>
</head>
<body>
<p>Result: <%jsproc(3,4)%></p>
</body>
</html>
Practice Excercise Practice now
Differences Between VBScript And JavaScript
When calling a VBScript or a JavaScript procedure from an ASP file written in VBScript, you can use the "call" keyword followed by the procedure name. If a procedure requires parameters, the parameter list must be enclosed in parentheses when using the "call" keyword. If you omit the "call" keyword, the parameter list must not be enclosed in parentheses. If the procedure has no parameters, the parentheses are optional.
When calling a JavaScript or a VBScript procedure from an ASP file written in JavaScript, always use parentheses after the procedure name.
Practice Excercise Practice now
VBScript Procedures
VBScript has two kinds procedures:
- Sub procedure
- Function procedure
Practice Excercise Practice now
VBScript Sub Procedures
A Sub procedure:
- is a series of statements, enclosed by the Sub and End Sub statements
- can perform actions, but does not return a value
- can take arguments
some statements
End Sub
or
Sub mysub(argument1,argument2)some statements
End Sub
Example
response.write("I was written by a sub procedure")
End Sub
Practice Excercise Practice now
VBScript Function Procedures
A Function procedure:
- is a series of statements, enclosed by the Function and End Function statements
- can perform actions and can return a value
- can take arguments that are passed to it by a calling procedure
- without arguments, must include an empty set of parentheses ()
- returns a value by assigning a value to its name
Example
myfunction=Date()
end function
Practice Excercise Practice now
Calling A Procedure
This simple function procedures is called to calculate the sum of two arguments:
Example
myfunction=a+b
End Function
response.write(myfunction(5,9))
The function "myfunction" will return the sum of argument "a" and argument "b". In this case 14.
When you call a procedure you can use the Call statement, like this:
Call MyProc(argument)Or, you can omit the Call statement, like this:
MyProc argumentPractice Excercise Practice now
Products
Partner
Copyright © RVR Innovations LLP 2025 | All rights reserved - Mytat.co is the venture of RVR Innovations LLP