我有两个函数(其中一个在另一个内部调用),它们将一些变量作为参数共享,如下例所示:
Public Function f1(a as Double, b as Double, c as Double)
"code"
End
Public Function f2(a as Double, b as Double, c as Double, t as Integer)
var = f1(a, b, c)
"code"
End
有没有办法在这两个函数之外只声明一次重复变量(a,b和c),如下所示:
Dim a As Double, b As Double, c As Double
Public Function f1(a, b, c)
"code"
End
Public Function f2(a, b, c, t as Integer)
var = f1(a, b, c)
"code"
End
或者那些特定于其父函数的参数?
答案 0 :(得分:0)
一种方法,定义全局变量,不要将它们用作函数的参数。
Dim a As Double, b As Double, c As Double
Public Function f1()
"code use a,b and c"
End
Public Function f2(t as Integer)
var = f1()
"code use a,b and c"
End