这样也会下标越界?另外,为什么编译器只提示错误但没有了“调试”按钮?
For Each Objt In SeleObjts
If TypeOf Objt Is AcadLine Then
nLine = nLine + 1: ReDim Preserve Lines(1 To nLine): Set Lines(nLine) = Objt
End If
Next Objt
‘以下代码经过我测试可以正常运行
Sub test()
'创建选择集
Dim seleobjts As AcadSelectionSet
Set seleobjts = ThisDrawing.SelectionSets.Add(Time)
seleobjts.SelectOnScreen
'你的代码部分
Dim nline As Integer
Dim lines() As AcadObject
Dim objt As AcadObject
For Each objt In seleobjts
If TypeOf objt Is AcadLine Then
nline = nline + 1: ReDim Preserve lines(1 To nline): Set lines(nline) = objt
End If
Next objt
'检查结果
a = lines()
MsgBox UBound(a)
End Sub