ASP — Variables
Declaring Variables
<%
Dim x
Dim name
Dim price, quantity
%>
Assigning Values
<%
Dim x
x = 5
Dim name
name = "John"
Dim pi
pi = 3.14159
%>
Output Variables
<%
Dim name
name = "John"
Response.Write("Hello, " & name)
%>
Variable Scope
<%
' Local variable
Dim localVar
localVar = 10
' Session variable
Session("username") = "John"
' Application variable
Application("counter") = 0
%>
Option Explicit
<%@ Language=VBScript %>
<% Option Explicit %>
<%
Dim x
x = 5 ' Works
y = 10 ' Error - not declared
%>
Mini Practice
- Declare variables
- Assign values
- Output variables
- Use Option Explicit
Up Next
Continue with Data Types — ASP data types.
Related Topics
Frequently Asked Questions about Variables
What is Variables in ASP?
Variables is a fundamental concept in ASP. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Variables?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Variables.
Why is Variables important in ASP?
Variables is essential for ASP development. Understanding this concept will help you write better code and solve real-world problems more effectively.