VB循环中Resume Next只执行一次
本人用VB操作AutoCAD,用ResumeNext扑捉错误信息的时候,第一次可以扑捉到,第二次就不行了~着急啊~下面是主要代码,望高手给予帮助!DimacadUtilA...
本人用VB操作AutoCAD,用Resume Next扑捉错误信息的时候,第一次可以扑捉到,第二次就不行了~着急啊~下面是主要代码,望高手给予帮助!
Dim acadUtil As Object
Dim stPnt As Variant
Set acadUtil = ACADDoc.Utility '设置AutoCAD Active Document对象
On Error Resume Next
' Define the valid keywords
Dim keywordList As String, InputString As String
keywordList = "Next Undo Close Finish Erase"
' Call InitializeUserInput to set up the keywords
acadUtil.InitializeUserInput 128, keywordList
Dim finish As Boolean
finish = False
While finish = False
stPnt = acadUtil.GetPoint(stPnt, "选择下一点[N]/撤销上一点[U]/闭合[C]/结束[F]/取消[E]:<N>")
If Err.Number = 0 Then
finish = True
ElseIf StrComp(Err.Description, "User input is a keyword", 1) = 0 Or StrComp(Err.Description, "用户输入的是关键字", 1) = 0 Then
Err.Clear
InputString = ACADDoc.Utility.GetInput
If StrComp(InputString, "Undo", 1) = 0 Then
'撤销上一步操作
ElseIf StrComp(InputString, "Close", 1) = 0 Then
'执行闭合操作
Set acadUtil = Nothing
finish = true
ElseIf StrComp(InputString, "Finish", 1) = 0 Then
Set acadUtil = Nothing
finish = true
ElseIf StrComp(InputString, "Erase", 1) = 0 Then
'执行取消操作
Set acadUtil = Nothing
finish = true
End If
Else
Set acadUtil = Nothing
Exit Sub
End If
Wend
总的来说是通过VB与CAD的交互实现CAD下PLine的操作。我第一次输入关键字的时候可以扑捉到错误信息,第二次输入关键字的时候就执行不到错误信息判断行了,直接在CAD中显示“无效点”,望大虾们给予解决!谢谢了~
逐鹿传说:你说的太模糊了~不是很明白~我是在怀疑CAD中不支持~我在VBA中也试过CAD中Activex的例程,也是只执行一次~望有过这方面编程经验的大侠们给予指点~谢谢! 展开
Dim acadUtil As Object
Dim stPnt As Variant
Set acadUtil = ACADDoc.Utility '设置AutoCAD Active Document对象
On Error Resume Next
' Define the valid keywords
Dim keywordList As String, InputString As String
keywordList = "Next Undo Close Finish Erase"
' Call InitializeUserInput to set up the keywords
acadUtil.InitializeUserInput 128, keywordList
Dim finish As Boolean
finish = False
While finish = False
stPnt = acadUtil.GetPoint(stPnt, "选择下一点[N]/撤销上一点[U]/闭合[C]/结束[F]/取消[E]:<N>")
If Err.Number = 0 Then
finish = True
ElseIf StrComp(Err.Description, "User input is a keyword", 1) = 0 Or StrComp(Err.Description, "用户输入的是关键字", 1) = 0 Then
Err.Clear
InputString = ACADDoc.Utility.GetInput
If StrComp(InputString, "Undo", 1) = 0 Then
'撤销上一步操作
ElseIf StrComp(InputString, "Close", 1) = 0 Then
'执行闭合操作
Set acadUtil = Nothing
finish = true
ElseIf StrComp(InputString, "Finish", 1) = 0 Then
Set acadUtil = Nothing
finish = true
ElseIf StrComp(InputString, "Erase", 1) = 0 Then
'执行取消操作
Set acadUtil = Nothing
finish = true
End If
Else
Set acadUtil = Nothing
Exit Sub
End If
Wend
总的来说是通过VB与CAD的交互实现CAD下PLine的操作。我第一次输入关键字的时候可以扑捉到错误信息,第二次输入关键字的时候就执行不到错误信息判断行了,直接在CAD中显示“无效点”,望大虾们给予解决!谢谢了~
逐鹿传说:你说的太模糊了~不是很明白~我是在怀疑CAD中不支持~我在VBA中也试过CAD中Activex的例程,也是只执行一次~望有过这方面编程经验的大侠们给予指点~谢谢! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询