明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1517|回复: 1

在vb中使用类来处理事件(帮忙看看如何修改代码)

[复制链接]
发表于 2004-7-26 17:21:00 | 显示全部楼层 |阅读模式
类模块eventclassmodule里的代码:
Option Explicit
Public WithEvents Doc As AcadDocument
Public Sub AcadDocument_ObjectModified(ByVal obj As AcadObject)
MsgBox "A " & TypeName(object) & " was just modified!"
End Sub 窗体模块中的代码:
Option Explicit
Dim acadApp As AcadApplication
Dim X As New EventClassModule Private Sub Form_Load()
On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox ("²»ÄÜÔËÐÐAutoCAD2004,Çë¼ì²éÊÇ·ñ°²×°ÁËAutoCAD2004")
Exit Sub
End If
End If
acadApp.Visible = True
acadApp.WindowState = acMax
X.Doc = AcadApplication.ActiveDocument
Dim lineObj As AcadLine
Dim startPoint(0 To 2) As Double
Dim endPoint(0 To 2) As Double

startPoint(0) = 1#: startPoint(1) = 1#: startPoint(2) = 0#
endPoint(0) = 5#: endPoint(1) = 5#: endPoint(2) = 0#

Set lineObj = AcadApplication.ActiveDocument.ModelSpace.AddLine(startPoint, endPoint)

Me.Hide
End Sub 请教如何改动,才能够在改动直线时,触发事件?
谢谢指教。
发表于 2004-7-26 21:35:00 | 显示全部楼层
vb里做事件比较痛苦,为什么不用VBA呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-28 03:41 , Processed in 0.177181 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表