在建立螺栓、螺母等标准件图形图库,用数组要要比其它方式,简单方便。下面程序是建立法兰图形数据库时,用数组建立数据库,比用MDB+SQL方式,工作效率要高的多。 Function HG20592Array() As Double() Dim HG20592(3), bb(3) As Double 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) 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) 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) 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) For ii = 0 To 3 bb(ii) = HG20592(ii)(2) Next ii HG20592Array = bb End Function Sub ls() Dim aa() As Double aa = HG20592Array For ii = 0 To 3 Debug.Print aa(ii) Next ii End Sub 切记在function和SUB中涉及到数组的数据类型定义必须要统一,如dim aa() as double必须统一,否而要出问题。 |