Office中国论坛/Access中国论坛

标题: 请高手支招!!! [打印本页]

作者: zhaohong    时间: 2004-8-20 22:54
标题: 请高手支招!!!
我从别人那得到一个计算树木的材积程序,我想通过它转成access中的程序模块,但出现了错误,请各位好友指点哦!!!小子不胜感激。

10 D%=3

20 DIM A#(3),B#(3),C#(3),A1#(3),B1#(3)

30 DIM A2#(5,3),B2#(5,3),K%(5,3)

40 FOR I%=1 TO 3

50 READ A#(I%),B#(I%),C#(I%),A1#(I%),B1#(I%)

60 NEXT I%

70 FOR I%=1 TO 5

80 FOR J%=1 TO 3

90 READ A2#(I%,J%),B2#(I%,J%),K%(I%,J%)

100 NEXT J%

110 NEXT I%

120 DATA .000058061860,1.9558851,.89408804,.10945,.97432

130 DATA .000062341803,1.8551497,.95682492,.34879,.96410

140 DATA .000050479055,1.9085054,.99076507,.29814,.96370

150 DATA 28.3226,-645.2923,20,41.1547,-2277.2073,57,32.5420,-1152.7459,37

160 DATA 53.6998,-3389.5577,63,47.2481,-2975.1142,63,34.2245,-1331.0611,41

170 DATA 37.26899,-1136.0444,28,35.5685,-944.3192,23,37.8524,-1241.7049,31

180 DATA 37.5221,-1388.5695,35,40.0347,-1416.1801,32,46.3460,-2374.4336,51

190 DATA 33.8504,-1020.9832,29,74.3141,-7420.0166,102,30.4809,-1070.7755,36

195 INPUT "树种";I%

200 INPUT "胸径";R2

210 IF R2=-1 THEN END

230 M1#=A1#(I%)+B1#(I%)*R2

240 M2#=A2#(D%,I%)+B2#(D%,I%)/(M1#+K%(D%,I%))

260 V#=A#(I%)*M1#^B#(I%)*M2#^C#(I%)

270 PRINT USING "##.###";V#

280 GOTO 195

290 NEXT I%

上为GWBASIC程序,

以下是我在access中写的模块:

Function treev()



Dim K As Integer

Dim A(2) As String, B(2) As String, C(2) As String, A1(2) As String, B1(2) As String

Dim A2(0 To 4, 0 To 2) As String, B2(0 To 4, 0 To 2) As String, K2(0 To 4, 0 To 2) As String

<FONT size=3><FONT face="Times New R
作者: yangzn    时间: 2004-8-20 23:48
我倒,这种东西也找到了.主要先要把这个程序读懂 然后根据数理逻辑 把 “DATA .000058061860,1.9558851,.89408804,.10945,.97432 ”语句的内容改成Acess的表   " READ A#(I%),B#(I%),C#(I%),A1#(I%),B1#(I%) "语改为 用DAO 或 Ado 的记录集 去访问表中的数据


作者: zhaohong    时间: 2004-8-21 00:27
  " READ A#(I%),B#(I%),C#(I%),A1#(I%),B1#(I%) "语改为 用DAO 或 Ado 的记录集 去访问表中的数据

关健在此,我就是不知怎样将表中的数据赋于数组
作者: yangzn    时间: 2004-8-22 18:30
    Dim rst As New ADODB.Recordset

    Dim a() As Variant  '如果数组知道长度,就用定长数组,变量类型也是如此

    Dim i As Long

    '这里插入 rst的打开

    '并定位到你要的那条记录

    '然后....

   

    ReDim a(rst.Fields.Count)

    For i = 0 To rst.Fields.Count - 1

        a(i) = rst(i)

    Next i




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3