|
Variables are used to store the information. In ASP it is not required to declare your variables but it is a good programming practice to declare all your variables before you use them, even though it is not required. In ASP you declare a variable with the use of the Dim keyword, which is short for Dimension. Variables can be declared one at a time or all at once. Here is the example.
<%
DIM var1
DIM var2, var3
%>
Assigning values to variables:
<%
DIM var1
DIM var2, var3
var1=”Hello”
var2=100
var3=2000
response.write(var1 & “<br>”)
response.write(var2 & “<br>”)
response.write(var3 & “<br>”)
%>
Variables Lifetime:
A variable declared outside a procedure can be accessed and changed by any script in the ASP file.
A variable declared inside a procedure can be accessed and changed only in that procedure. No scripts outside the procedure can access or change the variable.
If you want to access variable in more than one ASP file, you can declare them as a session or application variable. |