Constants in Classic ASP and VBScript

Last updated: August 25, 2026.

A constant gives a readable name to a value that should not change while a Classic ASP page runs. In VBScript, declare application constants with the Const statement.

Declare and use constants

<%
Const TAX_RATE = 0.0825
Const STATUS_ACTIVE = "active"
Const MAX_PAGE_SIZE = 100

Dim subtotal
subtotal = 250
Response.Write FormatCurrency(subtotal * (1 + TAX_RATE))
%>

A Const expression can contain literals and other constants, but not a function call or value read at runtime. Use an ordinary variable for environment-specific configuration.

Component constants

ADO and other COM components define their own constants. Include a trusted constants file or declare the component type library in the application, then use names such as adCmdText instead of unexplained numbers.

<!-- #include virtual="/includes/adovbs.inc" -->
<%
command.CommandType = adCmdText
%>

Keep include files outside writable upload directories and do not build include paths from request values. Microsoft documents constants and component type libraries in Using Variables and Constants.

admin

admin

Leave a Reply

Your email address will not be published.