Sub ShuRu() Dim xhobj As AcadText Dim xuhao As Integer xuahao = ThisDrawing.Utility.GetString(1, vbCrLf & "序号:") Dim datatype(0 To 1) As Integer Dim data(0 To 1) As Variant datatype(0) = 1001: data(0) = "number" datatype(1) = 1000: data(1) = "xuhao" xhobj.SetXData datatype, data End Sub
请问上面的代码能将用户输入的序号的值加入到xhobj的文本对象中吗?我运行后提示错误91,为什么呢?
Sub test() Dim xhobj As AcadText Dim xuhao As Integer Dim pnt(2) As Double xuahao = ThisDrawing.Utility.GetString(1, vbCrLf & "序号:") Set xhobj = ThisDrawing.ModelSpace.AddText(xuahao, pnt, 5) Dim datatype(0 To 1) As Integer Dim data(0 To 1) As Variant datatype(0) = 1001: data(0) = "我的序号" datatype(1) = 1000: data(1) = xuahao xhobj.SetXData datatype, data End Sub