Foxtable(狐表)用户栏目专家坐堂 → 自定义函数的使用


  共有3815人关注过本帖树形打印复制链接

主题:自定义函数的使用

美女呀,离线,留言给我吧!
朱女士
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:513 积分:4073 威望:0 精华:0 注册:2020/2/8 11:14:00
自定义函数的使用  发帖心情 Post By:2022/3/2 13:12:00 [只看该作者]

老师您好!
   我将昨天提出的问题,用了自定义函数,参数args()的定义,是不是所有主程序中所有传到到函数中的变量,我定义了60 来个参数,在调用时,还得逐个写上去吗?能用循序语句吗?例如:
Dim wr As DataRow = args(0)
Dim tcjgz As Double=args(1)
Dim dt5 As Date= args(2)
Dim dt6 As Date= args(3)
Dim xm As String= args(4)
Dim tgh As Double= args(5)
Dim tgh1 As Double=args(6)

Dim tgh2 As Double=args(7)
Dim tzb1 As Double=args(8)
Dim tzb2 As Double=args(9)
Dim tghyl As Double=args(10)
Dim tghyl1 As Double=args(11)
Dim tghyl2 As Double=args(12)
Dim tcz As Double=args(13)

Dim tcz1 As Double =args(14)
Dim tcz2 As Double=args(15)
Dim tcb As Double =args(16)
Dim tcbcc As Double=args(17)
Dim tcbcz As Double= args(18)
Dim tsba As Double=args(19)

Dim tzj As Double= args(20)
Dim twhf As Double=args(21)
Dim tsj As Double = args(22)
Dim tyhf As Double= args(23)
Dim tfzf As Double= args(24)
Dim tbzf As Double= args(25)
Dim tyclf As Double=args(26)

Dim tccf As Double= args(27)
Dim tfyb As Double=args(28)
Dim tglgz As Double=args(29)
Dim tglsb As Double=args(30)
Dim tyyf As Double=args(32)
Dim tclf As Double=args(33)

Dim tlcf As Double= args(34)
Dim tzdf As Double=args(35)
Dim tgzff As Double= args(36)
Dim tfyc As Double= args(37)
Dim tdklx As Double= args(38)
Dim tqtcwf As Double= args(39)

Dim tyxglfy As Double= args(40)
Dim tyxxglfy1 As Double=args(41)
Dim tyxglfy2 As Double= args(42)
Dim twxglfy As Double= args(43)
Dim twxglfy1 As Double= args(44)
Dim twxglfy2 As Double= args(45)
Dim tylf As Double=args(46)
Dim tfya As Double=args(47)
Dim tfya3 As Double=args(48)
Dim tfya31 As Double=args(49)
Dim tfya32 As Double=args(50)
Dim tylf1 As Double=args(51)
Dim tylf2 As Double=args(52)
Dim tbgf As Double=args(53)
Dim tyxglfy1 As Double=args(54)
Dim tlr As Double=args(55)
Dim tcb1 As Double=args(56)
Dim tcb2 As Double=args(57)
Dim tyxcb1 As Double=args(58)
Dim tyxcb2 As Double=args(59)
Dim tyxcb As Double=args(60)


 Functions.Execute("运算函数1",wr,tcjgz,dt5 ,dt6,xm,tgh...)
    
谢谢!

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110744 积分:563646 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/3/2 13:36:00 [只看该作者]

一般函数里用到多少个变量就传入多少个变量。如果需要传入这么多参数,应该是代码的逻辑设计有问题。

如果变量只在函数内使用,就直接在函数内部定义,不需要在外部定义再传入。

可以使用数组的方式传入参数,比如

dim aa(2) as string
aa(0) = "xxx1"
aa(1) = "xxx2"
aa(2) = "xxx3"
Functions.Execute("运算函数1",aa)

 回到顶部