兰州人 发表于 2007-10-25 20:53:00

数组function返回数组变量标准程式

<p>在建立螺栓、螺母等标准件图形图库,用数组要要比其它方式,简单方便。下面程序是建立法兰图形数据库时,用数组建立数据库,比用MDB+SQL方式,工作效率要高的多。</p><p>Function HG20592Array() As Double()<br/>&nbsp; Dim HG20592(3), bb(3) As Double<br/>&nbsp; HG20592(0) = Array(10, 15, 20, 25, 32, 40, 50, 65, 80, 100, 125, 150, 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000, 1200, 1400, 1600, 1800, 2000)<br/>&nbsp; HG20592(1) = Array(33, 38, 48, 58, 69, 78, 88, 108, 124, 144, 174, 199, 254, 309, 363, 413, 463, 518, 568, 667, 772, 878, 978, 1078, 1295, 1510, 1710, 1918, 2125)<br/>&nbsp; HG20592(2) = Array(33, 38, 48, 58, 69, 78, 88, 108, 124, 144, 174, 199, 254, 309, 363, 413, 463, 518, 568, 667, 772, 878, 978, 1078, 1295, 1510, 1710, 1918, 2125)<br/>&nbsp; HG20592(3) = Array(41, 46, 56, 65, 76, 84, 99, 118, 132, 156, 184, 211, 266, 319, 370, 429, 480, 530, 582, 682, 794, 901, 1001, 1112, 1328, 1530, 1750, 1950, 2125)<br/>&nbsp; <br/>&nbsp;&nbsp; For ii = 0 To 3<br/>&nbsp;&nbsp;&nbsp; bb(ii) = HG20592(ii)(2)<br/>&nbsp;&nbsp; Next ii<br/>&nbsp; HG20592Array = bb<br/>End Function</p><p>Sub ls()<br/>&nbsp; Dim aa() As Double<br/>&nbsp; aa = HG20592Array<br/>&nbsp; <br/>&nbsp; For ii = 0 To 3<br/>&nbsp;&nbsp;&nbsp; Debug.Print aa(ii)<br/>&nbsp; Next ii<br/>End Sub</p><p></p><p>切记在function和SUB中涉及到数组的数据类型定义必须要统一,如dim aa() as double必须统一,否而要出问题。</p><p></p>
页: [1]
查看完整版本: 数组function返回数组变量标准程式