Sub CADJSQ_qh() 'CAD计算器 Dim txt_type As String Dim sset As AcadSelectionSet Dim i As Integer, j As Integer Dim qh As Double qh = 0 Set sset = ThisDrawing.SelectionSets.Add("qh") '定义选择集 If Err Then Set sset = ThisDrawing.SelectionSets.Add("wzxg"): sset.Clear sset.SelectOnScreen '提升用户选择对象 For i = 0 To sset.Count - 1 txt_type = sset.Item(i).ObjectName If txt_type = "AcDbText" Or txt_type = "AcDbMText" Then qh = qh + sset.Item(i).TextString End If Next MsgBox "当前所选择数据的总和为" & qh sset.Delete End Sub