ASP: Declaring Varaibles
As you might know any asp script needs to be written inside the delimiter
<% %>
Now that you have this mind, let’s go ahead and declare some variables:
<html>
<body>
<%
Dim Name,
Dim Age,
Dim
Occupation
name="Michael Jordan"
response.write("My name is: " & Name)
response.write("My
age is: " & Age)
response.write("My
job is: " & Occupation)
%>
</body>
</html>
As you can see we declared three variables, notice whenever you declare a variable you must declare it as dim. Secondly the asp script is not case sensitive so you don’t need to make the first alphabet capital unlike some other programming languages.
Now let go ahead and declare an array of size 5.
<html>
<body>
<%
Dim name(5), i
name(1) = "Jan Egil"
name(2) = "Tove"
name(3) = "Hege"
name(4) = "Stale"
name(5) = "Kai Jim"
For i = 1 to 5
response.write(name(i) & "<br />")
Next
%>
</body>
</html>
Now the output will be like this:
Jan Egil,
Tove,
Hege,
Stale,
Kai Jim,
Borge
|