这样可以只选择数据字符,就不用IsNumeric判断了
Sub tt() On Error Resume Next Dim ss As AcadSelectionSet Dim ft(2) As Integer, fd(2) ThisDrawing.SelectionSets("Test").Delete Set ss = ThisDrawing.SelectionSets.Add("Test") ft(0) = 0: fd(0) = "*Text" ft(1) = 1: fd(1) = "~*[~.0-9]*" ft(2) = 1: fd(2) = "~*.*.*" ss.SelectOnScreen ft, fd textvalue = 0 For Each i In ss textvalue = textvalue + Val(i.TextString) Next MsgBox "The result is:" & textvalue End Sub
|