Variables in Classic ASP and VBScript

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.
  • Session and Application store values beyond one request; use them sparingly and lock shared Application updates.
admin

admin

Leave a Reply

Your email address will not be published.