xinghesnak
发表于 2006-3-9 13:22:00
isnumber是VB自带的函数啊!有问题?
雪山飞狐_lzh
发表于 2006-3-9 13:51:00
Sub tt()<BR>On Error Resume Next<BR>Dim ss As AcadSelectionSet<BR>Dim ft(0) As Integer, fd(0)<BR>ThisDrawing.SelectionSets("Test").Delete<BR>Set ss = ThisDrawing.SelectionSets.Add("Test")<BR>ft(0) = 0: fd(0) = "*Text"<BR> ss.SelectOnScreen ft, fd<BR> textvalue = 0<BR> For Each i In ss<BR> If IsNumeric(i.TextString) Then<BR> textvalue = textvalue + Val(i.TextString)<BR> End If<BR> Next<BR> MsgBox "The result is:" & textvalue<BR>End Sub<BR>
xinghesnak
发表于 2006-3-9 14:56:00
<P>呵呵!是IsNumeric不是IsNumber,记错了......</P>
雪山飞狐_lzh
发表于 2006-3-22 22:01:00
<P>这样可以只选择数据字符,就不用IsNumeric判断了</P>
<P>Sub tt()<BR>On Error Resume Next<BR>Dim ss As AcadSelectionSet<BR>Dim ft(2) As Integer, fd(2)<BR>ThisDrawing.SelectionSets("Test").Delete<BR>Set ss = ThisDrawing.SelectionSets.Add("Test")<BR>ft(0) = 0: fd(0) = "*Text"<BR>ft(1) = 1: fd(1) = "~*[~.0-9]*"<BR>ft(2) = 1: fd(2) = "~*.*.*"<BR> ss.SelectOnScreen ft, fd<BR> textvalue = 0<BR> For Each i In ss<BR> textvalue = textvalue + Val(i.TextString)<BR> Next<BR> MsgBox "The result is:" & textvalue<BR>End Sub</P>
<P><BR> </P>