VBScript variables in Classic ASP

ASP ( VB Script ) provides also easy use of variables but some of the basic syntax is to be followed. One of the biggest advantage of ASP variables is it is not case sensitive. If I declare a variable as my_var then I can still access the same variable by calling it as My_var.

We also have to follow some syntax for declaring variables.

All variables declared must start with a letter. Number or any other key are not accepted as variable. So variable name like 1my_var is not accepted but my1_var is accepted.

Length of the variable name should not exceed 255 characters.

Space period and dashes are not allowed within the variable name.

Reserve words are not allowed. Example we can't declare response as a variable
Dim userName
On this page — Show page sectionsHide page sections

The best way is to be use descriptive variable names for easy understand of the purpose and identification. Birth date variable should be declared as variable like birth_date

We will use more ASP code and see the use of variables in other tutorials.
ASP Variables
Explicit declaration of variables
Getting the data type of the variable using TypeName
Typecasting variables in ASP
ASP Introdution

Use Option Explicit to catch typos

<%@ Language=VBScript %>
<% Option Explicit %>
<%
Dim language
language = "VBScript"
Response.Write language
%>

Output:

VBScript

Declare the variable before using it. Without a declaration, a misspelled variable name becomes a compilation error instead of silently returning an empty value.

Avoid subtle variable bugs

VBScript variable names are not case-sensitive. Use Option Explicit and declare variables with Dim to catch accidental misspellings rather than silently creating new variables.

Back to top ↑


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer