Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of Const statement in VBS

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "the usage of Const sentence in VBS". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the usage of Const sentence in VBS.

Declares a constant used instead of a literal value.

[Public | Private] Const constname = expression

Parameter Public

Optional. This keyword is used to declare constants at the Script level that are available to all procedures in all scripts. Use is not allowed in the process.

Private

Optional. This keyword is used to declare constants at the script level that can only be used in the script in which the declaration is located. Use is not allowed in the process.

Constname

Required. The name of the constant, according to the standard variable naming convention.

Expression

Required. Literals or other constants, or any combination of all arithmetic and logical operators except Is.

Description

By default, constants are common. The constants in the process are always proprietary and their visibility cannot be changed. In Script, the Private keyword is used to change the default value for the visibility of script-level constants.

To declare several constants on the same line, each constant assignment is separated by a comma. When declaring constants in this way, if the Public or Private keyword is used, the keyword is valid for all constants in the line.

Variables, user-defined functions, or VBScript internal functions (such as Chr) cannot be used in constant declarations. By definition, they cannot be constants. In addition, you cannot create constants from expressions that contain operators, that is, only simple constants are allowed. The constant declared in the Sub or Function procedure is the local constant of the process. The constant declared outside the procedure is the global constant in the script in which the declaration is made. You can use constants wherever expressions are used. The following code illustrates how to use the Const statement:

The Const MyVar = 459 'constant is public by default. Private Const MyString = "HELP" 'defines a private constant. Const MyStr = "Hello", MyNumber = 3.4567 'defines multiple constants on one line. Note that constants make the script self-supporting and easy to modify. Unlike variables, constants cannot be inadvertently modified when a script is running.

Thank you for reading, the above is the content of "the usage of Const sentence in VBS". After the study of this article, I believe you have a deeper understanding of the usage of Const sentence in VBS, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report