asp
asp
EACT
MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
ASP Procedures
❮ Previous Next ❯
In ASP you can call a JavaScript procedure from a VBScript and vice versa.
Procedures
The ASP source code can contain procedures and functions:
Example
<!DOCTYPE html>
<html>
<head>
<%
sub vbproc(num1,num2)
response.write(num1*num2)
end sub
%>
</head>
<body>
</body>
</html>
https://www.w3schools.com/asp/asp_procedures.asp 1/10
11/6/24, 7:00 AM ASP VB Procedures
ShowTutorials
Example »
Exercises Services Sign Up Log in
EACT
MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
Insert the <%@ language="language" %> line above the <html> tag to write the
procedure/function in another scripting language:
Example
<%@ language="javascript" %>
<!DOCTYPE html>
<html>
<head>
<%
function jsproc(num1,num2)
{
Response.Write(num1*num2)
}
%>
</head>
<body>
<p>Result: <%jsproc(3,4)%></p>
</body>
</html>
Show Example »
ADVERTISEMENT
https://www.w3schools.com/asp/asp_procedures.asp 2/10
11/6/24, 7:00 AM ASP VB Procedures
Ads by
Tutorials We'll
Exercises try
Ad not to show
closed
Services by that adagain
Stop seeing this ad
Sign Up Log in
EACT
MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
Why this ad?
When calling a JavaScript or a VBScript procedure from an ASP file written in JavaScript,
always use parentheses after the procedure name.
VBScript Procedures
VBScript has two kinds procedures:
Sub procedure
Function procedure
https://www.w3schools.com/asp/asp_procedures.asp 3/10
11/6/24, 7:00 AM ASP VB Procedures
Subsomemysub()
Tutorials
statements
Exercises Services Sign Up Log in
End
EACT Sub
MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
or
Sub mysub(argument1,argument2)
some statements
End Sub
Example
Sub mysub()
response.write("I was written by a sub procedure")
End Sub
Show Example »
Function myfunction()
some statements
myfunction=some value
End Function
or
https://www.w3schools.com/asp/asp_procedures.asp 4/10
11/6/24, 7:00 AM ASP VB Procedures
Function myfunction(argument1,argument2)
Tutorials
some statements
Exercises Services Sign Up Log in
EACT
myfunction=some
MYSQL JQUERYvalue
EXCEL XML DJANGO NUMPY PANDAS NODEJS R
End Function
Example
function myfunction()
myfunction=Date()
end function
Show Example »
Calling a Procedure
This simple function procedures is called to calculate the sum of two arguments:
Example
Function myfunction(a,b)
myfunction=a+b
End Function
response.write(myfunction(5,9))
Show Example »
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:
https://www.w3schools.com/asp/asp_procedures.asp 5/10
11/6/24, 6:55 AM ASP VB Syntax
EACT
MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
ASP Syntax
❮ Previous Next ❯
ASP Files
ASP files can be ordinary HTML files. In addition, ASP files can also contain server
scripts.
https://www.w3schools.com/asp/asp_syntax.asp 1/8
11/6/24, 6:55 AM ASP VB Syntax
Tutorials
Example Exercises Services Sign Up Log in
EACT
MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
<!DOCTYPE html>
<html>
<body>
<%
Response.Write("Hello World!")
%>
</body>
</html>
Show Example »
Example
<%@ language="javascript"%>
<!DOCTYPE html>
<html>
<body>
<%
Response.Write("Hello World!")
%>
</body>
</html>
https://www.w3schools.com/asp/asp_syntax.asp 2/8
11/6/24, 6:55 AM ASP VB Syntax
EACT
MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
ADVERTISEMENT
More Examples
There is an easy shortcut to Response.Write(). You can use an equal sign (=) instead.
Example
<!DOCTYPE html>
<html>
<body>
<%
="Hello World!"
%>
</body>
</html>
Show Example »
https://www.w3schools.com/asp/asp_syntax.asp 3/8
11/6/24, 6:55 AM ASP VB Syntax
EACT
MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
Example
<!DOCTYPE html>
<html>
<body>
<%
Response.Write("<h2>You can use HTML tags to format the text!</h2>")
%>
</body>
</html>
Show Example »
Example
<!DOCTYPE html>
<html>
<body>
<%
Response.Write("<p style='color:#0000ff'>This text is styled.</p>")
%>
</body>
</html>
Show Example »
VBScript Examples
This tutorial contains a lot of VBScript examples.
https://www.w3schools.com/asp/asp_syntax.asp 4/8
11/6/24, 6:56 AM ASP VB Variables
EACT
MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
ASP Variables
❮ Previous Next ❯
More Examples
Declare a variable
This example demonstrates how to declare a variable, assign a value to it, and use the
value in a text.
Create an array
Arrays are used to store a series of related data items. This example demonstrates how
to create an array that stores names.
https://www.w3schools.com/asp/asp_variables.asp 1/10
11/6/24, 6:56 AM ASP VB Variables
EACT
MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
Do you remember that a letter (like x) could be used to hold a value (like 5), and that
you could use the information above to calculate the value of z to be 11?
These letters are called variables, and variables can be used to hold values (x=5) or
expressions (z=x+y).
VBScript Variables
As with algebra, VBScript variables are used to hold values or expressions.
A variable can have a short name, like x, or a more descriptive name, like carname.
In VBScript, all variables are of type variant, that can store different types of data.
ADVERTISEMENT
You can declare VBScript variables with the Dim, Public or the Private statement. Like
this:
Dim x
Dim carname
https://www.w3schools.com/asp/asp_variables.asp 2/10
11/6/24, 6:56 AM ASP VB Variables
Now you have created two variables. The name of the variables are "x" and "carname".
Tutorials Exercises Services Sign Up Log in
You can also declare variables by using its name in a script. Like this:
EACT
MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
carname="Volvo"
Now you have also created a variable. The name of the variable is "carname". However,
this method is not a good practice, because you can misspell the variable name later in
your script, and that can cause strange results when your script is running.
If you misspell for example the "carname" variable to "carnime", the script will
automatically create a new variable called "carnime". To prevent your script from doing
this, you can use the Option Explicit statement. This statement forces you to declare all
your variables with the dim, public or private statement.
Put the Option Explicit statement on the top of your script. Like this:
Option Explicit
Dim carname
carname=some value
carname="Volvo"
x=10
The variable name is on the left side of the expression and the value you want to assign
to the variable is on the right. Now the variable "carname" has the value of "Volvo", and
the variable "x" has the value of "10".
https://www.w3schools.com/asp/asp_variables.asp 3/10
11/6/24, 6:56 AM ASP VB Variables
Dim names(2)
Tutorials Exercises Services Sign Up Log in
The MYSQL
EACT number shown
JQUERY in the EXCEL
parentheses
XMLis 2. DJANGO
We start at NUMPY
zero so this array contains
PANDAS 3
NODEJS R
elements. This is a fixed-size array. You assign data to each of the elements of the array
like this:
names(0)="Tove"
names(1)="Jani"
names(2)="Stale"
Similarly, the data can be retrieved from any element using the index of the particular
array element you want. Like this:
mother=names(0)
Dim table(4,6)
Example
<html>
<body>
<%
Dim x(2,2)
x(0,0)="Volvo"
x(0,1)="BMW"
x(0,2)="Ford"
x(1,0)="Apple"
x(1,1)="Orange"
x(1,2)="Banana"
x(2,0)="Coke"
x(2,1)="Pepsi"
x(2,2)="Sprite"
for i=0 to 2
https://www.w3schools.com/asp/asp_variables.asp 4/10
11/6/24, 6:56 AM ASP VB Variables
response.write("<p>")
Tutorials
for j=0 to 2 Exercises Services Sign Up Log in
response.write(x(i,j) & "<br />")
EACT
MYSQL
next JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R
response.write("</p>")
next
%>
</body>
</html>
Show Example »
A variable declared inside a procedure is created and destroyed every time the
procedure is executed. No scripts outside the procedure can access or change the
variable.
To declare variables accessible to more than one ASP file, declare them as session
variables or application variables.
Session Variables
Session variables are used to store information about ONE single user, and are available
to all pages in one application. Typically information stored in session variables are
name, id, and preferences.
Application Variables
Application variables are also available to all pages in one application. Application
variables are used to store information about ALL users in one specific application.
❮ Previous Next ❯
https://www.w3schools.com/asp/asp_variables.asp 5/10