Bryco 发表于 2007-3-12 17:30:40

我真的不想打一匹死马,但我觉得这句话太离谱了;以下是其中一个模块Option Explicit
Public Const VK_ESCAPE = &H1B
Public Const VK_LBUTTON = &H1
Public Const VK_SPACE = &H20
Public Const VK_RETURN = &HD
Public Const VK_LEFT = &H25
Public Declare Function GetAsyncKeyState Lib "user32" _
                                       (ByVal vKey As Long) As Integer
Public Function AddBKR()
      Dim dimsc As Integer
      dimsc = ThisDrawing.GetVariable("DIMSCALE")
      Dim InsPT As Variant
      Dim intOsMode As Integer
      Dim dblRotation As Double
      Dim objBlockRef As AcadBlockReference
      '************** Esc Code *************
      Dim varCancel As Variant
      On Error GoTo Err_Control
      '************** Esc Code *************
      Call LayerSet("3D-EQPM", acRed)
      intOsMode = ThisDrawing.GetVariable("OSMODE")
      ThisDrawing.SetVariable "OSMODE", 32
      InsPT = ThisDrawing.Utility.GetPoint(, "Pick Insertion Point: ")
      ThisDrawing.SetVariable "OSMODE", 512
      dblRotation = ThisDrawing.Utility.GetAngle(InsPT, "Pick Cabinet Side: ")
      Set objBlockRef = ThisDrawing.ModelSpace.InsertBlock(InsPT, Path & "breaker.dwg", 1, 1, 1, dblRotation)
      '************** Esc Code *************
Exit_Here:
      LayerReSet
      ThisDrawing.SetVariable "OSMODE", intOsMode
      ThisDrawing.SetVariable "DIMSCALE", dimsc
      ThisDrawing.SetVariable "INSUNITS", 1
      Exit Function
Err_Control:
      Select Case Err.Number
            Case -2147352567
                  'Debug.Print Err.Number, Err.Description
                  varCancel = ThisDrawing.GetVariable("LASTPROMPT")
                  If InStr(1, varCancel, "*Cancel*")0 Then
                        If GetAsyncKeyState(VK_ESCAPE) And 8000 > 0 Then
                              Err.Clear
                              Resume Exit_Here
                        ElseIf GetAsyncKeyState(VK_LBUTTON) > 0 Then
                              Err.Clear
                              Resume
                        End If
                  Else
                        If GetAsyncKeyState(VK_SPACE) Then
                              Resume Exit_Here
                        End If
                        'Missed the pick, send them back!
                        Err.Clear
                        Resume
                  End If
            Case Else
                  MsgBox Err.Description
                  Resume Exit_Here
      End Select
End Function
你说的改变是什么
Option Explicit
Public Enum CloseMode
CloseMode_Close=???
CloseMode_Cancel=&H1B' Added here and I would reference CloseMode.CloseMode_Cancel?
End Enum
Public Declare Function GetAsyncKeyState Lib "user32" _
                                       (ByVal vKey As Long) As Integer
Public Function AddBKR()
      Dim dimsc As Integer
      dimsc = ThisDrawing.GetVariable("DIMSCALE")
      Dim InsPT As Variant
      Dim intOsMode As Integer
      Dim dblRotation As Double
      Dim objBlockRef As AcadBlockReference
      '************** Esc Code *************
      Dim varCancel As Variant
      On Error GoTo Err_Control
      '************** Esc Code *************
      Call LayerSet("3D-EQPM", acRed)
      intOsMode = ThisDrawing.GetVariable("OSMODE")
      ThisDrawing.SetVariable "OSMODE", 32
      InsPT = ThisDrawing.Utility.GetPoint(, "Pick Insertion Point: ")
      ThisDrawing.SetVariable "OSMODE", 512
      dblRotation = ThisDrawing.Utility.GetAngle(InsPT, "Pick Cabinet Side: ")
      Set objBlockRef = ThisDrawing.ModelSpace.InsertBlock(InsPT, Path & "breaker.dwg", 1, 1, 1, dblRotation)
      '************** Esc Code *************
Exit_Here:
      LayerReSet
      ThisDrawing.SetVariable "OSMODE", intOsMode
      ThisDrawing.SetVariable "DIMSCALE", dimsc
      ThisDrawing.SetVariable "INSUNITS", 1
      Exit Function
Err_Control:
      Select Case Err.Number
            Case -2147352567
                  'Debug.Print Err.Number, Err.Description
                  varCancel = ThisDrawing.GetVariable("LASTPROMPT")
                  If InStr(1, varCancel, "*Cancel*")0 Then
                        If GetAsyncKeyState(VK_ESCAPE) And 8000 > 0 Then
                              Err.Clear
                              Resume Exit_Here
                        ElseIf GetAsyncKeyState(VK_LBUTTON) > 0 Then
                              Err.Clear
                              Resume
                        End If
                  Else
                        If GetAsyncKeyState(VK_SPACE) Then
                              Resume Exit_Here
                        End If
                        'Missed the pick, send them back!
                        Err.Clear
                        Resume
                  End If
            Case Else
                  MsgBox Err.Description
                  Resume Exit_Here
      End Select
End Function

Kerry 发表于 2007-3-12 17:32:20

枚举会以init代码的形式出现吗 我意识到我发布了一个模块作为示例

Kerry 发表于 2007-3-12 19:09:52

本人'等我有时间的时候再看,但是把const设为私有,它应该可以正常工作。

Bryco 发表于 2007-3-13 09:30:29


不完全是 我没有'我不是说你应该完全使用我发布的内容 只是一般形式;这里有一些更适合你特殊需要的东西
Public Enum VirtualKeys
ESCAPE = &H1B
LBUTTON = &H1
SPACE = &H20
RETURN = &HD
LEFT = &H25
End Enum
顺便提一下,在我发布的另一个示例中,我没有't显式地为枚举的每个成员分配一个值,因为它在我从中提取的代码中是不相关的 枚举应该在文件范围内(在任何过程之外)
顺便提一下 我认为布莱科是对的 仅仅将公共Const改为私人Const更为方便 对不起,如果我'我把你引向了一场白费力气的追逐。

Kerry 发表于 2007-3-13 19:19:08

你好,大卫,我想你会得到更好的服务;“业务”;思维方式尤其是当您在OOP语言中做更多工作时。
页: 1 [2]
查看完整版本: 模块拆分或表单代码