在VBScript中實現函數的方法

學識都 人氣:6.3K

在JS中有這種用法,某個函數名可以當成參數的形式,傳入到另外一個函數內部去,例如:

在VBScript中實現函數的方法

在VBScript有兩種方式可以來實現,即用execute或GetRef函數。

一、利用execute:

FunctionmyFuncA(str,myFuncName)

str=str&"您好!"

execute("str="&myFuncName&"(str)")

myFuncA=str

EndFunction

FunctionmyFuncB(str)

str=str+"歡迎來到"

myFuncB=str

EndFunction

msgboxmyFuncA("張三","myFuncB")

二、利用GetRef:

FunctionmyFuncA(str,myB)

str=str&"您好!"

str=myB(str)

myFuncA=str

EndFunction

FunctionmyFuncB(str)

str=str+"歡迎來到"

myFuncB=str

EndFunction

e(myFuncA("張三",GetRef("myFuncB")))