以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 自定义函数的使用 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=175366) |
-- 作者:朱女士 -- 发布时间: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...) 谢谢! |
-- 作者:有点蓝 -- 发布时间:2022/3/2 13:36:00 -- 一般函数里用到多少个变量就传入多少个变量。如果需要传入这么多参数,应该是代码的逻辑设计有问题。 如果变量只在函数内使用,就直接在函数内部定义,不需要在外部定义再传入。 可以使用数组的方式传入参数,比如 dim aa(2) as string aa(0) = "xxx1" aa(1) = "xxx2" aa(2) = "xxx3" Functions.Execute("运算函数1",aa)
|