找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 361|回复: 0

[VBA函数]:大家给我看看我的vba程序问题在哪里呀

[复制链接]
发表于 2004-7-30 16:57:29 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我用vba例子里的程序改了个给文本求和的程序(见附件)
可是总也实现不了
只能在状态拦显示每次选择的文本值  没有求和

以下是我的类模块
大家帮忙给看看

'Following is the code from the clsAddText class.


Implements IPrimitiveCommandEvents
Dim m_otextElement As TextElement
Dim total As Double
Private Sub IPrimitiveCommandEvents_Cleanup()

End Sub
Private Function Locatetext(Point As Point3d, View As View) As TextElement

On Error GoTo NoElement
    ' LocateElement will locate any type of element, but if it returns
    ' an element that is not an text then VBA will generate an error
    ' when it tries to store the object reference in Locatetext.
    Set Locatetext = CommandState.LocateElement(Point, View, True)
NoElement:

End Function

Private Sub IPrimitiveCommandEvents_DataPoint(Point As Point3d, ByVal View As View)
        If m_otextElement Is Nothing Then
        '  This is the first data point. Use it to locate an text
        Set m_otextElement = Locatetext(Point, View)
        If m_otextElement Is Nothing Then
            ShowError "No text Found"
            Exit Sub
        End If
        
   
    total = Val(m_otextElement.Text) + Val(total)
    ShowStatus "Total=" & total
   
    CommandState.StartPrimitive New clsAddText
   
    End If
End Sub

Private Sub IPrimitiveCommandEvents_Dynamics(Point As Point3d, ByVal View As View, ByVal DrawMode As MsdDrawingMode)
    If m_otextElement Is Nothing Then
        Exit Sub
    End If
End Sub
Private Sub IPrimitiveCommandEvents_Keyin(ByVal Keyin As String)

End Sub

Private Sub IPrimitiveCommandEvents_Reset()
    If Not m_otextElement Is Nothing Then
        m_otextElement.Redraw msdDrawingModeTemporaryErase
    End If

    '  Start from the beginning, using a new object to
    '  be certain that it is completely reinitialized.

    CommandState.StartPrimitive New clsAddText

End Sub

Private Sub IPrimitiveCommandEvents_Start()
    ShowCommand "Vba Modify text"
    ShowPrompt "Select text"
    CommandState.SetLocateCursor
End Sub


这几个事件的发生顺序如何的
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-24 07:35 , Processed in 0.262465 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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