withevents xxx as class1是什么意思?

yulohan 2003-08-21 10:30:44
withevents xxx as class1是什么意思?
...全文
118 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
liul17 2003-08-21
  • 打赏
  • 举报
回复
帮你UP

好像是: 声明个事件 ,这个事件的具体内容在类class1中(是我猜的)
qingming81 2003-08-21
  • 打赏
  • 举报
回复
定义XXX为Class1的类模块事件。

Handling an Object's Events

An object that raises events is called an event source. To handle the events raised by an event source, you can declare a variable of the object's class using the WithEvents keyword.

This topic continues the Widget object example begun in "Declaring and Raising Events." To handle the PercentDone event of a Widget, place the following code in the Declarations section of Form1:

Option Explicit
Private WithEvents mWidget As Widget
Private mblnCancel As Boolean

The WithEvents keyword specifies that the variable mWidget will be used to handle an object's events. You specify the kind of object by supplying the name of the class from which the object will be created.

The variable mWidget is declared in the Declarations section of Form1 because WithEvents variables must be module-level variables. This is true regardless of the type of module you place them in.

The variable mblnCancel will be used to cancel the LongTask method.

Limitations on WithEvents Variables
You should be aware of the following limitations on the use of WithEvents variables:

A WithEvents variable cannot be a generic object variable. That is, you cannot declare it As Object — you must specify the class name when you declare the variable.


You cannot declare a WithEvents variable As New. The event source object must be explicitly created and assigned to the WithEvents variable.


You cannot declare WithEvents variables in a standard module. You can declare them only in class modules, form modules, and other modules that define classes.


You cannot create arrays of WithEvents variables.

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧