Export (0) Print
Expand All

Defining Constants

Microsoft® Windows® 2000 Scripting Guide

Constants are defined in VBScript by using the Const statement followed by the name and value of the constant. When you define a constant, you must assign it a literal value; you cannot assign a value to a constant by using a variable, another constant, or a function. For example, the following code sample, which attempts to define a constant using the variable NumberOfDepartments, will generate an "Expected literal constant" error:



NumberOfDepartments = 20
Const NUMBER_OF_DEPARTMENTS = NumberOfDepartments

Instead, assign the constant the literal value 20:



Const NUMBER_OF_DEPARTMENTS = 20

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft