bsirhell 发表于 2006-7-17 19:14:00

[求助]字符个数计数

<P>现在想一次先输出T的数量,然后输出R的数量,请问该怎么改?</P>
<P>&nbsp;Sub co()</P>
<P>&nbsp;&nbsp;&nbsp; Dim SSet As AcadSelectionSet<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; Dim obj As AcadText<BR>&nbsp;&nbsp;&nbsp; Dim ptcen(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim endPoint1(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim endPoint2(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim cline As AcadLine<BR>&nbsp;&nbsp;&nbsp; Dim lineHalfLength As Double<BR>&nbsp;&nbsp;&nbsp; Dim groupCode(0 To 4) As Integer<BR>&nbsp;&nbsp;&nbsp; Dim dataValue(0 To 4) As Variant<BR>&nbsp;&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; On Error Resume Next<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; If Not IsNull(ThisDrawing.SelectionSets.Item("tex")) Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set SSet = ThisDrawing.SelectionSets.Item("tex")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SSet.Delete<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Set SSet = ThisDrawing.SelectionSets.Add("ArcsCirclesEllipses")<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; '设置选择过滤器<BR>&nbsp;&nbsp;&nbsp; groupCode(0) = -4<BR>&nbsp;&nbsp;&nbsp; dataValue(0) = "&lt;or"<BR>&nbsp;&nbsp;&nbsp; groupCode(1) = 0<BR>&nbsp;&nbsp;&nbsp; dataValue(1) = "0"<BR>&nbsp;&nbsp;&nbsp; groupCode(2) = 0<BR>&nbsp;&nbsp;&nbsp; dataValue(2) = "text"<BR>&nbsp;&nbsp;&nbsp; groupCode(3) = 0<BR>&nbsp;&nbsp;&nbsp; dataValue(3) = "0"<BR>&nbsp;&nbsp;&nbsp; groupCode(4) = -4<BR>&nbsp;&nbsp;&nbsp; dataValue(4) = "or&gt;"<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; '提示用户选择<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.Utility.Prompt "选择" &amp; vbCr<BR>&nbsp;&nbsp;&nbsp; SSet.SelectOnScreen groupCode, dataValue<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; For Each obj In SSet<BR>&nbsp;&nbsp;&nbsp; If obj.TextString = "T" Then<BR>&nbsp;&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; obj.Update<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; MsgBox "共有T" &amp; i<BR>&nbsp;&nbsp; If obj.TextString = "R" Then<BR>&nbsp;&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; obj.Update<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; MsgBox "共有R" &amp; i<BR>&nbsp;&nbsp;&nbsp; Next obj<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>End Sub<BR></P>

雪山飞狐_lzh 发表于 2006-7-18 12:33:00

<P>你能解释下下这里是什么意思么?</P>
<P>groupCode(1) = 0<BR>dataValue(1) = "0"<BR></P>

bsirhell 发表于 2006-7-21 21:46:00

<P>groupCode(1) = 0<BR>dataValue(1) = "0"</P>
<P>是原过滤器过滤多种数据!<BR></P><BR>

雪山飞狐_lzh 发表于 2006-7-21 23:58:00

<P>没有这种做法:)</P>
<P>groupCode数组表示DXF组码</P>
<P>dataValue数组表示对应组码的数值</P>
<P>组码0表示一个实体的图元类型</P>
<P>关于这些具体可以看看DXF组码的帮助部分</P>
<P>好像上次做过一次的</P>
<P>设置过滤器为</P>
<P>0,"Text",1,"T"</P>
<P>就可以过滤出T的数量</P>
页: [1]
查看完整版本: [求助]字符个数计数