'将选取的数字相加 '本过程演示SelectOnScreen方法的使用 On Error Resume Next If ThisDrawing.SelectionSets.count <> 0 Then For I = 0 To ThisDrawing.SelectionSets.count - 1 Set ssetObj = ThisDrawing.SelectionSets(I) ssetObj.delete Next End If
Set ssetObj = ThisDrawing.SelectionSets.Add("sset4") Unload UserForm10 '让用户在屏幕上选择要加入选择集的图元 ssetObj.SelectOnScreen '将选择集中的文本转变成数字后相加 textvalue = 0 For I = 0 To ssetObj.count - 1 If ssetObj.Item(I).ObjectName = "AcDbText" Then 'textvalue = textvalue * Val(ssetObj.Item(i).textstring) 'ssetObj.Item(i).textstring = textvalue textvalue = textvalue + Val(ssetObj.Item(I).textstring) End If Next MsgBox "The result is:" & textvalue
|