查看完整版本: [-- ASP编程问题:怎么把数组作为子过程参数来传递? --]

狗狗静电BBS - wwW.DoGGiEhoMe.CoM -> 电脑全方位 Computer Guide -> ASP编程问题:怎么把数组作为子过程参数来传递? [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

bbsriver 2010-11-15 14:46
前面定义了一个动态数组myArr()

set tempRs=Server.CreateObject("Adodb.Recordset")
tempRs.open "select * from sheet1 where id=123",conn,1,1  '读取Sql数据库
    dim myArr()  '定义数组
    Redim myArr(tempRs.recordcount-1)  '数组元素个数等于数据库中的记录条数
    i=0
        do while not tempRS.eof
            myArr(i)=tempRS("name")  '把数据库中的记录逐条赋值给数组的每个元素
            tempRS.movenext
            i=i+1
        loop
tempRS.close
set tempRS=nothing

后面有个子过程,假设名字就叫sub deal_myArr,需要调用这个数组当参数。语句应该怎么写呢?就像普通变量当参数一样写可以吗?

galilette 2010-11-15 15:42
http://bytes.com/topic/asp-classic/answers/53828-can-asp-pass-array-into-function

galilette 2010-11-15 15:42
google搜索 passing dynamic array as parameter

天堂有令 2010-11-15 16:28
似乎和ASP么啥关系,是不是VB函数参数传数组的问题?

网上抄了段代码,据说调试能过
Copy code

Private  Sub  Command1_Click()
Dim  x(9)  As  Integer
Dim  i  As  Integer

For  i  =  0  To  9
    x(i)  =  i
Next

    Call  iArr(x)

End  Sub


Private  Function  iArr(arr()  As  Integer)  As  Integer
   
  Dim  i  As  Integer

  For  i  =  0  To  UBound(arr)
        Debug.Print  arr(i)
  Next
   
End  Function

飞甩鸡毛2 2010-11-16 23:53
你的数组定义在哪个区间啊,是不是可以对那个子过程可用

bbsriver 2010-11-17 09:23
可用。子过程放在#including当中。

bbsriver 2010-12-02 22:47
嗯,我终于看明白上面几楼给的几个例子了……

miwaep 2023-01-07 10:25
梦想是一个"双面人":在年少的时候,它离人们那么远,那么渺茫,那么不真实;而在壮年时,它离人们那么近,那么清晰,那么令人振奋。因为,壮年时的人们取得了成就,已经超越了自我,而在那成功的背后,洒下的是数不尽的汗滴与血泪。
幸运飞艇走势图福彩双色球走势图幸运时时彩走势图


查看完整版本: [-- ASP编程问题:怎么把数组作为子过程参数来传递? --] [-- top --]



Powered by PHPWind v6.0 Code © 2003-05 PHPWind
Gzip enabled

You can contact us