The difference between set and dim in ASP (Own understanding) _ Application Techniques

Source: Internet
Author: User
----------------------------explanations from the Internet---------------------------------
Dim is used to define a variable, set to specify an object for a variable, or to assign a value to an object variable.
Like Dim a
In fact, VBScript can not be defined directly on the use of
a=10
Dim conn
Set Conn=server.createobject ("Adodb.connection")
Set cannot be omitted.
------------------------------the content of self understanding---------------------------------
ASP language, Option explict force definition variable (good programming habits, preferably open)
① define variable →② variable assignment
Copy Code code as follows:

Dim A, conn ' here defines two variables, where we define a as a non-object variable (variable type), while Conn is an object variable (variable type)
A = "This is the test!!!" ' We assign a value to this variable, which is a string variable without the SET statement because it is not an object variable
Set Conn=server.createobject ("Adodb.connection") ' When we assign a value to this object variable we need to use the SET statement.

Dim is generally used to declare variables such as Dim variable name as data type
Set is generally used to assign values to special data types, such as those written above, because it is not possible to assign values simply by using the = number. Generally, connection command Recordset, and so on, are assigned using set.

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.