Quality is delighting customers
What is the difference in passing values ByRef or ByVal to a function? Can anyone pls explain with detailed examples?
Thanks,
Suma.
Tags:
Hi Suma,
The paramerters passed to a function can be either call by value or call by ref, the default is call by ref
By Ref: If the value is changed in the function the parameter value is also changed.
By Val: If the value is changed in the function the parameter value is not changed
Eg:
dim a,b
a=10
b=20
function f1(byval x, byref y)
x=100
y=200
end function
call f1(a,b)
msgbox a&" "&b
output is 10, 200
http://www.qualitytesting.info/forum/topics/can-any-body-explain-ca...
Please refer once Forum posts,Just before post.
Just FYI:
If you pass any DP objects you should use ByRef.
QTP use by default ByRef.
--Subbu.
Agreed with Mr.Srini Vuggumudi.
Thanks,
Shiv
In byval function we the value to the arguments
where as in byref we the reference (variable which storing the value) to the argument
Eg public function sum(byval a, byvalb)
sum=a+b
End function
call sum(20,30)
eg public funcation sum(byref a,byref b)
sum =a+b
End funcation
x=10,y=20
call sum(x,y)
Regards,
Ramesh kongara
© 2021 Created by Quality Testing.
Powered by