473,511 Members | 14,052 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ


Variables in ASP

By Robert Murdock
Programmer, Darpac Inc.

Variables:

All variables in ASP are defined as Variants. What does this mean to you? You will never need to declare a variable as an string or integer you just declare it. Here is an example of how you may assign variables:

Example (example3.asp):

<@ LANGUAGE="VBSCRIPT" %> <%
  'First we will declare a few variables.

  Dim SomeText
  Dim SomeNum

  'Next we will assign a value to these.

  SomeText = "ASP is great!"
  SomeNum = 1

  'Note that SomeText is a string and SomeNum is numeric.

  'Next we will display these to the user.

  Response.Write(SomeText)
  Response.Write(SomeNum)

  'You may also add (append) HTML code to these.

  Response.Write ("Right now you are thinking that " & SomeText)

%>

You can also mix HTML and ASP. In the following example I will show you this. It is the same as example three but the comments will be removed.

Example (example3b.asp):

<@ LANGUAGE="VBSCRIPT" %> <%
  Dim SomeText
  Dim SomeNum

  SomeText = "ASP is great!"
  SomeNum = 1
%>

<HTML>
<TITLE>Example 3b</TITLE>
<BODY>

<CENTER>Example 3b</CENTER>
<BR><BR>
Right now you are thinking that <%=SomeText%>
<BR><BR>
We have also defined SomeNum with the value of <%=SomeNum%>
</BODY>
</HTML>

This should be good enough to get you on your feet. Visit thescripts.com homepage for access to more coding tutorials.

« What is ASP?  

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.