[求助]AddLightWeightPolyline不能创建可变的多线段吗?
<FONT face=宋体 size=2>Dim points(0 To 5) As Double<BR><BR>' 为二维多段线顶点赋值<BR>points(0) = 2: points(1) = 4<BR>points(2) = 4: points(3) = 2<BR>points(4) = 6: points(5) = 4<BR><BR>Set plineObj = doc1.ModelSpace.AddLightWeightPolyline(points)<BR><BR>上面的没有任何问题<BR><BR>但如果我有一个字符串如下:<BR>dim objstr as string=<BR>"0,0|740.4857,0|740.4857,-89.8498|0,-89.8498"<BR>通过objstr创建一个多线段,怎么老是出错呢?<BR><BR>'db是ado的一个记录集 dim db as new adodb.recordset<BR><BR>Dim points<BR>dim objsum,i as integer<BR><BR>objstr = Replace(objstr, "|", ",")<BR>points = Split(objstr, ",")<BR>objsum = db("summit_sum") * 2 - 1 'db("summit_sum") 是多线段的顶点个数<BR><BR>ReDim repoints(0 To objsum) As double <BR>'ReDim repoints(0 To objsum) As variant 这两种定义方式都不行<BR>''ReDim repoints(0 To objsum)<BR><BR>For i = 0 To objsum<BR>repoints(i) = points(i)<BR>Debug.Print points(i)<BR>Next<BR><BR>Set plineObj = doc1.ModelSpace.AddLightWeightPolyline(points)<BR>'这一句添加时老是出错:无效的过程调用或参数<BR>'我试了上面好几种定义方式都不行,</FONT> 可以啊.看看我的示例:i为可输入的大于等于3的奇数,Pvar通过循环付值
Sub test()<BR>Dim Pvar As Variant<BR>Dim Pline
Dim j<BR>i = 3<BR>ReDim Pvar(0 To i) As Double
'For j=0 To i<BR>Pvar(0) = 0: Pvar(1) = 0<BR>Pvar(2) = 100: Pvar(3) = 100
'Next<BR>Set Pline = ThisDrawing.ModelSpace.AddLightWeightPolyline(Pvar)
End Sub
页:
[1]