Vbs Tutorial: VBScript statement-const statement

Source: Internet
Author: User

Const statement

The Declaration is used to replace the constant of the text value.

[Public | private]ConstConstname = expression

Parameters

Public

Optional. This keyword is used to declare constants that can be used for all processes in all scripts at the script level. It cannot be used in the process.

Private

Optional. This keyword is used to declare constants that can only be used in the script where the declaration is located. It cannot be used in the process.

Constname

Required. Constant name, according to standard variable naming conventions.

Expression

Required. Text or other constants, or including DivisionIsAny combination of all Arithmetic Operators and logical operators.

Description

By default, constants are public. Constants in the process are always proprietary, and their visibility cannot be changed. Script, availablePrivateKeyword to change the default value of the script-level constant visibility.

Several constants must be declared in the same row. Each constant can be assigned a value with commas. If the constant is declared using this methodPublicOrPrivateKeyword, the keyword is valid for all constants in the row.

Variable, user-defined function, or VBScript internal function (suchCHR). By definition, they cannot be constants. In addition, you cannot create constants from expressions that contain operators. That is, you can only use simple constants. InSubOrFunctionThe constant declared in the process is the local constant of the process. The constant declared outside the process is the global constant in the script where the declaration is located. Constants can be used wherever expressions are used. BelowCodeExamplesConstStatement:

 
ConstMyvar = 459'Constant: Public.PrivateConstMystring = "help"'Defines the private constant.ConstMystr = "hello", mynumber = 3.4567.'Multiple constants are defined on one row.

Note:The constant can be supported by the script and can be easily modified. Unlike variables, constants cannot be accidentally modified when a script is running.

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.