Course Content
ASP Tutorial
About Lesson

Variables and Data Types in ASP

ASP (Active Server Pages) relies heavily on variables and data types to handle information dynamically. In ASP, variables act as containers for storing data temporarily, and data types define the kind of data that can be stored in these variables. Let’s delve into the world of variables and data types in ASP to grasp their significance and usage.

Declaring Variables in ASP

In ASP, declaring variables is straightforward. Use the Dim statement followed by the variable name to declare a variable. For instance:

Dim age
Dim name

This declares two variables, ‘age’ and ‘name’. Unlike some other programming languages, ASP doesn’t require explicit declaration of data types during variable declaration.

Data Types in ASP

ASP supports various data types to accommodate different kinds of data. Some of the primary data types include:


Strings are sequences of characters enclosed in double-quotes. Example:

Dim name
name = "John Doe"


Integers are whole numbers without any decimal points. Example:

Dim age
age = 25


Double data types hold numbers with decimal points. Example:

Dim price
price = 19.99


Boolean data types store either True or False. Example:

Dim isAvailable
isAvailable = True


Date data types hold date and time values. Example:

Dim currentDate
currentDate = Now

Understanding the usage and characteristics of these data types is crucial when handling different kinds of information within ASP.

Dynamic Typing in ASP

ASP is dynamically typed, meaning you can change the type of data stored in a variable at runtime. For instance, you can switch a variable from holding an integer to a string or any other data type based on the requirement.

Dim myVariable
myVariable = 10 ' myVariable is now an Integer
myVariable = "Hello" ' myVariable is now a String

However, while dynamic typing provides flexibility, it’s essential to manage data types carefully to avoid unexpected behaviors or errors in your code.