06622 发表于 2004-7-21 09:18:00

这是一位朋友的统计程序,哪位告诉我怎么用

我很需要它,可是我不会加载使用它!希望谁帮我解决一下!



Sub totalnumber()<BR>                       Dim total As Double<BR>                       total = 0<BR>                       Dim ssetObj As AcadSelectionSet<BR>                       Set ssetObj = CreateSelectionSet("numberobj")<BR>                       Dim ftype, fdata<BR>                       BuildFilter ftype, fdata, 0, "text"<BR>                       ssetObj.SelectOnScreen ftype, fdata<BR>                       For i = 0 To ssetObj.Count - 1<BR>                                                       If IsNumeric(ssetObj.Item(i).TextString) Then<BR>                                                                                       total = total + ssetObj.Item(i).TextString<BR>                                                               Else<BR>                                                       End If<BR>                       Next i





                       ssetobj.delete<BR>                       ActiveDocument.Utility.Prompt "总和=" &amp; total<BR>End Sub<BR>Public function CreateSelectionSet(Optional ssName As String = "ss") As AcadSelectionSet<BR>       '返回一个空白选择集<BR>       <BR>                       Dim ss As AcadSelectionSet<BR>                       <BR>                       On Error Resume Next<BR>                       Set ss = ThisDrawing.SelectionSets(ssName)<BR>                       If err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)<BR>                       ss.Clear<BR>                       Set CreateSelectionSet = ss<BR>End Function<BR>Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())<BR>                       '用数组方式填充一对变量以用作为选择集过滤器使用<BR>                       Dim ftype() As Integer, fdata()<BR>                       Dim index As Long, i As Long<BR>                       <BR>                       index = LBound(gCodes) - 1<BR>                                                       <BR>                       For i = LBound(gCodes) To UBound(gCodes) Step 2<BR>                                                       index = index + 1<BR>                                                       ReDim Preserve ftype(0 To index)<BR>                                                       ReDim Preserve fdata(0 To index)<BR>                                                       ftype(index) = CInt(gCodes(i))<BR>                                                       fdata(index) = gCodes(i + 1)<BR>                       Next<BR>                       typeArray = ftype: dataArray = fdata<BR>End Sub

06622 发表于 2004-7-21 10:00:00

我一直在线等,希望哪一位援手!

meflying 发表于 2004-7-21 10:28:00

你发的不是地方,这是VBA的程序,这里的LISP的版块,你应该去VBA版块等

06622 发表于 2004-7-21 10:34:00

谢谢,我知道了,我这就去,谢谢!
页: [1]
查看完整版本: 这是一位朋友的统计程序,哪位告诉我怎么用