ASP tutorials: ASP variables

Source: Internet
Author: User

ASP variable-vbscript
ASP is not the language itself. In order to plan the ASP actually, you need to know the VBScript scripting language. This means that the rules of all VBScript variables can be applied to your ASP code. This lesson will teach you the basic variables of ASP and some good programming conventions.


An ASP that declares a variable
It is a good programming practice to declare all the variables and then use them, even if it is not required. Almost all programming languages require you to declare variables and this will also increase the readability of your program.

You declare a variable using Dim keywords in asp, which is a short size. The size of English refers to the amount of space occupied by some in the real world, but in the computer refers to the space of computer memory.

A variable can be declared one or all at a time. Here is an example of both of these methods.

<%
' Single Variable Declarations
Dim myVar1
Dim MYVAR2
' Multiple Variable Declarations
Dim myVar6, MYVAR7, MYVAR8
%>

Variable ASP conventions
Again, use the default for ASP scripts, so also use the VBScripts variable naming convention. These rules are:

variable names must be a letter (A to Z or A to Z)
variable cannot contain a period
variable length cannot be longer than 255 characters (don't think it would be a problem!) The
variable must be a unique scope which declares (basically does not declare the same variable name in a script that you will determine).
ASP technology-Assigning value of a SP variable
the values assigned to the ASP are simple and clear enough to use only the equivalent of the "=" operator. Below we have set up a variable equivalent to a number and a separate variable equivalent to a string.

<%
' single Variable Declarations
Dim myString, MyNum, mygarbage
mynum = 25< br> myString = "Hello"
Mygarbage =
Mygarbage = "I changed my variable"
Response.Write ("MyNum =" &am P MyNum & "<br/>")
Response.Write ("myString =" & myString & "<br/>")
Response.Write ("Myga Rbage = "& Mygarbage & <br/>")
%>

Lost results.

MyNum = myString = Hello
Mygarbage = I changed my variable

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.