Variables are used to store information.
If a variable is declared outside the subroutine, then this variable can be changed by any script in the ASP file. If the variable is declared in the subroutine, it will be created and revoked when the subroutine is executed
Example:
Desenic variable
Variables are used to store information. This example demonstrates how to declare variables, assign a value for variables, and use this variable in the program
<html>
<body>
<%
dim name
name = donald duck
response.write (my name is: & name)
%>
</body>
</html>
Declaration array
The array is used to store a series of related data items. This example shows how to declare an array of a storage name.
<html>
<body>
<%
DIM FAMNAME (5), I
famname (0) = jan egil
famname (1) = TOVE
famname (2) = Hege
famname (3) = Stale
famname (4) = kai jim
famname (5) = Borge
For i = 0 to 5
response.write (FAMNAME (i) & <br />)
Next
%>
</body>
</html>
Cycling HTML Title
How to circulate 6 different HTML titles.
<html>
<body>
<%
dim I
for i = 1 to 6
Response.write (<H & I &> Header & I & </H & I &>)
next
%>
</body>
</html>
Use VBScript to make time -based greetings
This example will display different messages to users according to the server time.
<html>
<body>
<%
dim h
h = host (now ())
response.write (<p> & now ())
Response.write ((norwegian time) </p>)
If h <12te
response.write (Good Morning!)
else
response.write (good day!)
end if
%>
</body>
</html>
Use JavaScript to make time -based greetings
This example is the same as above, just the grammar is different.
< %@ Language = javascript %>
<html>
<body>
<%
var d = new date ()
var h = d.Gethourt ()
Response.write (<p>)
Response.write (D + (Norwegian Time))
Response.write (</p>)
if (h <12)
{{
Response.write (Good Morning!)
}
else
{{
Response.write (good day!)
}
%>
</body>
</html> The survival of variables
The convenience declared outside the subroutine can be accessed and modified by any script in the ASP file.
The variables declared in the child program are created and revoked only when the subroutine is executed. The script outside the subroutine cannot be accessed and modified the variable.
If you need to declare a variable used more than an ASP file, declare the variable as a session variable or Application variable.
Session variable
The session variable variable is used to store the information of a single user and is effective for all pages in an application. Typical data stored in session are names, IDs, or parameters.
Application variable
Application variables are also effective for all pages in an Application. Application variables are used to store information from all users in a specific Application.