Differences between set and dim in ASP

Source: Internet
Author: User

---------------------------- Explanations from the Internet ---------------------------------
Dim is used to define a variable. set is used to specify an object for a variable. It can also be understood as assigning values to the object variable.
For example, dim
In fact, vbscript can be used directly without definition.
A = 10
Dim conn
Set conn = server. createobject ("adodb. connection ")
Set cannot be omitted.

------------------------------ Self-understanding content ---------------------------------
ASP language, Option Explict forced definition of variables (good programming habits, it is best to enable)

① Define variables → ② assign values to variables

Dim a, conn' two variables are defined here, 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. It is a string variable and does not use the set statement because it is not an object variable.
Set conn = server. createobject ("adodb. connection") 'We must use the set statement when assigning values to this object variable.

 

DIM is generally used to declare variables, such as dim variable name as data type.
SET is generally used to assign values to some special data types, such as those written by the above side, because the = Sign alone cannot assign values. Generally, you must use set to assign values to connection command recordset.

 

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.