split+Array的应用
"aa|Mirr0|X600Y30ArrayX3Y4"主要是简化Array输入的一大堆数据.采用split,将上面数据进行数组转换.程序如下.
Sub ls1()
aa = "aa|Mirr0|X600Y30ArrayX3Y4"
ss = Split(aa, "|")
Dim xDist, yDist, numberOfRows, numberOfColumns
Dim Pt1(2) As Double, Pt2(2) As Double
Dim objLine As AcadLine, Ent As AcadEntity
Pt1(0) = 0: Pt1(1) = 10
Pt2(0) = 400: Pt2(1) = 10
Set objLine = ThisDrawing.ModelSpace.AddLine(Pt1, Pt2)
Dim xCopyPt(2) As Double, basePt(2) As Double
For ii = 0 To UBound(ss)
Debug.Print ss(ii)
If InStr(ss(ii), "Array") > 0 Then
bb = Split(ss(ii), "Array")
bbb = Split(bb(0), "Y")
xDist = Val(Mid(bbb(0), 2))
yDist = Val(bbb(1))
bbb = Split(bb(1), "Y")
numberOfColumns = Val(Mid(bbb(0), 2))
numberOfRows = Val(bbb(1))
Dim retObj As Variant
retObj = objLine.ArrayRectangular(numberOfRows, numberOfColumns, 1, yDist, xDist, 1)
End If
Next ii
End Sub
<p>这种方法不错,主要是简化了人工输入的一些工作,以前经常用到。一般来说,象我们写的小程序,速度并不是我们首先考虑的东西,实际上split对于大数据来说会比较慢。</p>
页:
[1]