看下面的两段代码:
A、参数通过引用传递
Function learnqtp( ByRef var)
myname= "li5tun"
msgbox var
msgbox myname
End Function
myname= "LI5TUN"
call learnqtp (myname)
B、参数通过值传递
Function learnqtp( ByVal var)
myname= "jain"
msgbox var
msgbox myname
End Function
myname= "ankur"
call learnqtp (myname)
代码A、代码B的输出分别是什么?为什么会是这样?实在想不起来就在QTP中运行一下!
Function learnqtp( ByRef var)
myname= "li5tun"
MsgBox var '此处var会动态读取传入参数myname的值,并且对var的修改会实时影响到myname的值
MsgBox myname
var = "zoey"
MsgBox myname
End Function
myname= "LI5TUN"
Call learnqtp (myname)
Function learnqtp1( ByVal var)
myname= "jain"
MsgBox var '此处var为传入时的myname的值,并且对var的修改不会影响到myname的值
MsgBox myname
var = "Sally"
MsgBox myname
End Function
myname= "ankur"
Call learnqtp1 (myname)