Option explicit statement in ASP

Source: Internet
Author: User

I encountered a problem today. I checked the option explicit statement online to find out what it meant.

Option explicit statement in ASP

It is used to force explicit declaration of all variables in the file at the file level.

Option explicit {on | off}

Description

On
Optional. Enable option explicit check. If on or off is not specified after the option explicit statement, the default value is on.
Off
Optional. Disable option explicit check.

Remarks

If this option is used, the option explicit statement must appear before all other source statements in the file.

When option explicit appears in a file, all variables must be explicitly declared using dim, private, public, or redim statements. An error occurred during compilation when trying to use an undeclared variable name.

If the option explicit statement is not used, all undeclared variables are of the object type.

Note that using option explicit can avoid misspelling the names of existing variables, or avoid ambiguity in the scope of variables.Code. If option explicit is not specified in the Code, the default setting of the compiler is option explicit on.

Example

In this example, the option explicit statement is used to force an explicit declaration of all variables. Attempting to use undeclared variables will cause compilation errors. The option explicit statement is only used at the module level.

Option explicit on 'force explicit variable declaration.

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.