变量“objSset”在赋值前被使用。可能会在运行时导致 null 引用异常
Public Sub ss()obj_Doc = obj_Acad.ActiveDocument
On Error GoTo err1
Dim objEntArr() As Object, i As Long
Dim objSset As AutoCAD.AcadSelectionSet
SelectAllText(objSset)
ReDim objEntArr(objSset.Count - 1)
For i = 0 To objSset.Count - 1
objEntArr(i) = objSset.Item(i)
Next i
XY_Sort(objEntArr)
For i = 0 To UBound(objEntArr)
objEntArr(i).TextString = objEntArr(i).TextString & CStr(i + 1)
Next i
Exit Sub
err1:
Err.Clear()
Debug.Print(Err.Description)
End Sub
VBA代码,VBA里没问题,粘贴到VB2010里提示警告 4 变量“objSset”在赋值前被使用。可能会在运行时导致 null 引用异常。 哪位高人能否指点下,谢谢
Dim objSset As AcadSelectionSet 1005100717 发表于 2018-6-6 21:14
Dim objSset As AcadSelectionSet
这样在Dim objSset As AcadSelectionSet,就直接出错了 redarrow2000 发表于 2018-6-6 21:56
这样在Dim objSset As AcadSelectionSet,就直接出错了
:funk:原来是VB,班门弄斧了,见笑了。
acadselectionset需要AcadSelectionSets 的add方法赋值,不知道有没有做。
Class name:
AcadSelectionSet
Create using:
SelectionSets.Add
Access via:
SelectionSets.Item
Document.ActiveSelectionSet
页:
[1]