Wednesday, December 28, 2011

VBScript GetRef Function

VBScript GetRef function returns a reference to a sub procedure or a function.

Copy the below VBScript code in QTP editor and see the output:

Function ShowMsg(ByVal sName)
ShowMsg = "Hello, " + sName
End Function

Set fnPtr = GetRef("ShowMsg")

After using GetRef, fnPtr actually contains a reference of our function "ShowMsg". It means, now onwards both the function and its reference will do the same thing.

Example, see the below code

Msgbox fnPtr("HP_QTP")

0 comments: