In our 'Variable' tutorial we showed
how a variable acts as a container holding or storing a value
in the server computer's memory. Well so does a constant.
With a variable we can change the value of the variable throughout our
code, with a constant we can't. Have a look at the code for example 1.
Example 1:
Note that the value of the variable myFavouriteTeam changes throughout
the script from Spurs to Spurs Reserves.
The value stored in a constant cannot change throughout the life
of a script or application after it has been declared.
To declare a const in VBScript we use the Const keyword. The constant is declared and assigned the value all on the same line.
In we attempt to re-assign the value of the constant as we did with the value of the variable we'll get a run time error.
Also note in the case above that strings require quotes and numeric values don't as shown below.
Get the best asp hosting provider from web-hosting-top.com and save up to 30%
Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.
