gaobin888 发表于 2005-12-8 18:09:00

请教,如何返回一个数组函数

请教,如何通过给定图块名称,返回该块的参数的数组函数

王咣生 发表于 2005-12-8 19:40:00

reply

<P>块的参数指什么,</P>
<P>可以用variant数组作为返回值</P>

gaobin888 发表于 2005-12-9 07:41:00

<P>描述有误,应该是块属性;</P>
<P>用variant试过,函数如下:</P>
<P>Public Function kuai(BlkName As String) As Variant</P>
<P>&nbsp;&nbsp; ReDim kuaisx(0 To 2, 0 To 0)</P>
<P>&nbsp;&nbsp; 。。。</P>
<P>&nbsp;&nbsp;&nbsp; kuai = kuaisx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'kuaisx为存储块属性的二维数组<BR>&nbsp;&nbsp;&nbsp; <BR>End Function</P>
<P>这么写对吗?该怎么引用?</P>

王咣生 发表于 2005-12-9 17:53:00

reply

<P>属性你怎么读的?不用二维数组也可以啊</P>
<P>&nbsp;&nbsp;&nbsp; ' Get the attributes<BR>&nbsp;&nbsp;&nbsp; Dim newvarAttributes As Variant<BR>&nbsp;&nbsp;&nbsp; newvarAttributes = blockRefObj.GetAttributes<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' Again, display the tags and values<BR>&nbsp;&nbsp;&nbsp; strAttributes = ""<BR>&nbsp;&nbsp;&nbsp; For I = LBound(varAttributes) To UBound(varAttributes)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strAttributes = strAttributes &amp; "&nbsp; Tag: " &amp; varAttributes(I).TagString &amp; _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&nbsp;&nbsp; Value: " &amp; varAttributes(I).textString &amp; "&nbsp;&nbsp;&nbsp; "<BR>&nbsp;&nbsp;&nbsp; Next<BR></P>

gaobin888 发表于 2005-12-10 16:38:00

谢谢版主,我的问题是:块中有序号、尺寸属性,要统计所有块中的属性,属性相同的保留一个,然后按序号排序,把结果放到数组中,这一步已经做到就是不知道函数该怎么写?你的方法给我启发,我会试试?
页: [1]
查看完整版本: 请教,如何返回一个数组函数