From SQP VBScript reference

简介:

Class Statement

Requirements

Version 5

<!--NONSCROLLING BANNER END-->

Declares the name of a class, as well as a definition of the variables, properties, and methods that comprise the class.

Class name
   statements
End Class 

Arguments

nameRequired. Name of the  Class; follows standard variable naming conventions. statementsRequired. One or more statements that define the variables, properties, and methods of the  Class.

Remarks

Within a Class block, members are declared as either Private or Public using the appropriate declaration statements. Anything declared as Private is visible only within the Class block. Anything declared as Public is visible within the Class block, as well as by code outside the Class block. Anything not explicitly declared as either Private or Public is Public by default. Procedures (either Sub or Function) declared Public within the class block become methods of the class. Public variables serve as properties of the class, as do properties explicitly declared using Property GetProperty Let, and Property Set. Default properties and methods for the class are specified in their declarations using the Default keyword. See the individual declaration statement topics for information on how this keyword is used.

 

Const Statement

Requirements

Version 5

<!--NONSCROLLING BANNER END-->

Declares constants for use in place of literal values.

[Public | Private] Const constname = expression

Arguments

PublicOptional. Keyword used at script level to declare constants that are available to all procedures in all scripts. Not allowed in procedures. PrivateOptional. Keyword used at script level to declare constants that are available only within the script where the declaration is made. Not allowed in procedures. constnameRequired. Name of the constant; follows standard variable naming conventions. expressionRequired. Literal or other constant, or any combination that includes all arithmetic or logical operators except  Is.

Remarks

Constants are public by default. Within procedures, constants are always private; their visibility can't be changed. Within a script, the default visibility of a script-level constant can be changed using the Privatekeyword.

To combine several constant declarations on the same line, separate each constant assignment with a comma. When constant declarations are combined in this way, the Public or Private keyword, if used, applies to all of them.

You can't use variables, user-defined functions, or intrinsic VBScript functions (such as Chr) in constant declarations. By definition, they can't be constants. You also can't create a constant from any expression that involves an operator, that is, only simple constants are allowed. Constants declared in a Sub or Functionprocedure are local to that procedure. A constant declared outside a procedure is defined throughout the script in which it is declared. You can use constants anywhere you can use an expression. The following code illustrates the use of the Const statement:

Const MyVar = 459   ' Constants are Public by default.
Private Const MyString = "HELP"   ' Declare Private constant.
Const MyStr = "Hello", MyNumber = 3.4567   ' Declare multiple constants on same line.

Note   Constants can make your scripts self-documenting and easy to modify. Unlike variables, constants cannot be inadvertently changed while your script is running.

 

Dim Statement

See Also

Private Statement | Public Statement | ReDim Statement | Set Statement

<!--Footer Start-->

Requirements

Version 1

<!--NONSCROLLING BANNER END-->

Declares variables and allocates storage space.

Dim varname[([subscripts])][, varname[([subscripts])]] . . .

Arguments

varnameName of the variable; follows standard variable naming conventions. subscriptsDimensions of an array variable; up to 60 multiple dimensions may be declared. The  subscriptsargument uses the following syntax:

upperbound [,upperbound] . . .

The lower bound of an array is always zero.

Remarks

Variables declared with Dim at the script level are available to all procedures within the script. At the procedure level, variables are available only within the procedure.

You can also use the Dim statement with empty parentheses to declare a dynamic array. After declaring a dynamic array, use the ReDim statement within a procedure to define the number of dimensions and elements in the array. If you try to redeclare a dimension for an array variable whose size was explicitly specified in a Dim statement, an error occurs.

Note   When you use the  Dim statement in a procedure, you generally put the  Dim statement at the beginning of the procedure.

The following examples illustrate the use of the Dim statement:

Dim Names(9)       ' Declare an array with 10 elements.
Dim Names()        ' Declare a dynamic array.
Dim MyVar, MyNum   ' Declare two variables.
相关文章
|
1月前
|
JavaScript 前端开发
javascript中的Symbol
javascript中的Symbol
|
7月前
|
XML JavaScript 编译器
TypeScript 里的 Reference Type 和 Triple-Slash Directives
TypeScript 里的 Reference Type 和 Triple-Slash Directives
37 0
|
5月前
|
JavaScript 前端开发
JavaScript中undefined和not defined的区别
JavaScript中undefined和not defined的区别
46 0
|
缓存 JavaScript 前端开发
JavaScript中的symbol类型
JavaScript中的symbol类型
|
JavaScript 前端开发 API
【译】Javascript中你需要知道的最出色的新特性:Optional Chaining
对于使用Javascript的每个人来说,可选链(Optional chaining)是游戏的规则的改变者。它与箭头函数或let和const一样重要。我们讨论下它可以解决什么问题,它如何工作,以及它如何使得你的生活更加轻松。
|
前端开发 JavaScript
escape in ABAP and JavaScript
escape in ABAP and JavaScript
81 0
escape in ABAP and JavaScript
|
JavaScript 前端开发 C语言
[译] JavaScript 中为什么会有 Symbol 类型?
[译] JavaScript 中为什么会有 Symbol 类型?
106 0
[译] JavaScript 中为什么会有 Symbol 类型?
|
JSON JavaScript 前端开发
JavaScript 为什么要有 Symbol 类型?
摘要: 为什么比怎么用更有意义。 原文:JavaScript 为什么要有 Symbol 类型 作者:前端小智 Symbols 是 ES6 引入了一个新的数据类型 ,它为 JS 带来了一些好处,尤其是对象属性时。
1241 0

热门文章

最新文章