| || |
how to call Global Variables into another function
Im trying to use a vaiable declared in a custom function which has a value.
Function X (CustNo1)
CustNo1 = 10
I want to access the above declared variable CustNo into another Funtion and assign it as Set property.
CustNo2 = X.CustNo1
Function Y( CustNo2)
Let me know if we can do this using QTP. how to declare global variable and retrive them in a different program or function.
Re: how to call Global Variables into another function
First i am assuming both your functions and your variable are declared in the same script/Action
Any variable declared with Dim outside a function has global scope there fore you can use it within the action/script it was declared in, thus:
myVariable = "someValue"
this variable will be accessible to any function in the same script thus:
when using variables like this there is no need to pass the variable to the function as it can already access it.
If your function is in a seperate script file then you will need to pass the variable as a parameter but i will suggest you pass it Byref since the default method (byval) sends a copy to the function and as such the original variable is not updated when you change something in your function.
I hope this helps