Sunday 8 February 2015

Difference between GetRef and Eval




Difference between GetRef and Eval
We cannot use GetRef when we have the required function call in different library ( Example if we have a sample function with name "TestEval" in a different library apart from where we have called GetRef to the function "TestEval". it will not work). we cannot use GetRef as it expects the function within its scope in the current library

On other hand Eval will work irrespective of where your Function is placed in library ( provided your library is associated to your test)

Example of using EVAL using multiple parameters:-

msg1 = "Hi "
msg2 = "Readers "
FunctionName = "TestEval"
Call Eval(FunctionName & chr(40) & "msg1" & chr(44) & "msg2" & chr(41))

Function TestEval(byval firstmessage, byval SecondMessage)
    msgbox firstmessage
    msgbox SecondMessage
    message = firstmessage & " " &  SecondMessage
     msgbox message
End Function

Example of using GetRef using multiple parameters:-

msg1 = "Hi "
msg2 = "Readers "
FunctionName = "TestEval"

Call GetRef(FunctionName)(msg1,msg2)

Function TestEval(byval firstmessage, byval SecondMessage)
    msgbox firstmessage
    msgbox SecondMessage
    message = firstmessage & " " &  SecondMessage
     msgbox message
End Function

Happy Reading,
Sreenu Babu




 

No comments:

Post a Comment