From SQP VBScript reference

Class Statement

See Also

Dim Statement | Function Statement | Private Statement | Property Get Statement | Property Let Statement |Property Set Statement | Public Statement | Set Statement | Sub Statement

<!--Footer Start-->

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

See Also

Dim Statement | Function Statement | Private Statement | Public Statement | Sub Statement

<!--Footer Start-->

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.
时间: 2024-09-02 18:47:59

From SQP VBScript reference的相关文章

《精通QTP——自动化测试技术领航》—第1章1.2节帮助文档(HELP)-QTP的说明书

1.2 帮助文档(HELP)-QTP的说明书 精通QTP--自动化测试技术领航 阶段要点 F1的简单介绍. 焦点功能引导法. 脚本定位跟踪法. 查阅Example实例技巧. 1.2.1 永远任劳任怨的良师益友"F1"1.2.1.1 "F1"的简单介绍 F1键相信很多朋友都不会陌生,举个最简单的例子,当用户打开Windows自带的notepad(记事本),按下F1键后,系统就会自动弹出notepad的帮助文档,如图1-3所示. 不止是notepad有F1,微软Offi

VBScript基础教程之十二在VBScript中使用对象

vbscript|对象|基础教程 使用对象 无论使用的是 ActiveX? 控件(以前称为 OLE 控件)还是 Java? 对象,Microsoft Visual Basic Scripting Edition 和 Microsoft? Internet Explorer 都以相同的方式处理它们.如果您使用的是 Internet Explorer 并且 ActiveX 库中安装了这些控件,就会看到由以下代码制作的页面. <OBJECT> 标记用来包含对象,<PARAM> 标记用来设

Visual Basic 6/VBScript 與Visual Basic.NET 的比較(下)

vbscript|visual 新的簡易設定(assignment)語法 Visual Basic.NET 提供新的簡易設定語法,當程式碼撰寫如下時   MyVal = 10 MyVal += 10 這時 MyVal 的值為 20 ,程式碼等於   MyVal = MyVal + 10 繼承(Inheritance) Visual Basic.NET 現今是一個完整的物件導向(Object Orient)語言,也就是完整支援封裝.繼承.多型等等程式撰寫的方式,並提供建構/解構子.所以它增加了以往

Visual Basic 6/VBScript 與Visual Basic.NET 的比較(中)

vbscript|visual 變數範圍(Variable Scope) Visual Basic.NET 讓 Local 變數支援 block 範圍,也就是在迴圈或 If 等等區塊內宣告的變數在外部是看不到的,所以若程式碼撰寫如下Imports System Namespace MyNamespace Module MyModule Sub Main() Dim j as integer For j=1 to 10If True Then Dim i As Integer i=i+1 Cons

VBS教程:在 VBScript 中使用对象_vbs

在 VBScript 中使用对象 使用对象 无论使用的是 ActiveX(R) 控件(以前称为 OLE 控件)还是 Java(TM) 对象,Microsoft Visual Basic Scripting Edition 和 Microsoft(R) Internet Explorer 都以相同的方式处理它们.如果您使用的是 Internet Explorer 并且安装了 Label 控件,就会看到由以下代码制作的页面. <OBJECT> 标记用来包含对象,<PARAM> 标记用来

VBScript教程 第十四课在VBScript中使用对象_vbs

使用对象 无论使用的是 ActiveX? 控件(以前称为 OLE 控件)还是 Java? 对象,Microsoft Visual Basic Scripting Edition 和 Microsoft? Internet Explorer 都以相同的方式处理它们.如果您使用的是 Internet Explorer 并且 ActiveX 库中安装了这些控件,就会看到由以下代码制作的页面. <OBJECT> 标记用来包含对象,<PARAM> 标记用来设置对象属性的初始值.使用 <

jscript与vbscript 操作XML元素属性的代码_XML示例

Although attributes belong to a particular element, they are not considered child nodes of element nodes. Instead, they behave more like properties of IXMLDOMElement. Most of the methods for working with attributes come from IXMLDOMElement. Attribute

ASP中一个字符串处理类(VBScript)

vbscript|字符串 这个类是用于处理字符串的,是老外写的,我把里面的功能和参数加了说明 使用方法: =============== test.asp================ <!--#include file="StringOperations.asp"--> <%dim strset str = New StringOperations test = str.toCharArray("check this out") respons

Custom tool error: Failed to generate code for the service reference &amp;#215;&amp;#215;&amp;#215;&amp;#215;&amp;#215;&amp;#215;. Please check other erro

开发工具:VS2010 问题描述: 在ProjectName.Web中创建的WebService服务,然后在项目中添加Add Service Reference,然后就报"Custom tool error: Failed togenerate code for the service reference ××××××. Please check other error andwarning messages for details. "这样的错误  新建.调用WebService 解