Last updated: August 26, 2026.
VBScript variables are declared with Dim and can hold different value types. Use Option Explicit so misspelled variable names become errors instead of new variables.
Declare and use variables
<%@ Language="VBScript" %>
<% Option Explicit %>
<%
Dim customerName, quantity, unitPrice, total
customerName = "Sam"
quantity = 3
unitPrice = 19.95
total = quantity * unitPrice
Response.Write Server.HTMLEncode(customerName)
Response.Write " owes " & FormatCurrency(total)
%>Scope
- Variables declared inside a procedure are local to it.
- Page-level variables are available throughout that ASP page.
SessionandApplicationstore values beyond one request; use them sparingly and lock shared Application updates.