Micro Focus QTP (UFT) Forums
Passing objects to Functions - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Passing objects to Functions (/Thread-Passing-objects-to-Functions)



Passing objects to Functions - vinod.nhce - 03-13-2014

I am trying to pass objects to functions and check if that particular object exists or not and depending on that functions would return true/false.
But the eval used here does not seems to work doing its job.
Object that i pass is of image type and it still goes inside if conditions after eval... any help plz

Code:
'In script file
'========
if WebApp_Exists( objHndM.Page("H&M IPS - Interior Production").Frame("navFrame"),"ButtonNew") then
objHndM.Page("H&M IPS - Interior Production").Frame("navFrame").Image("ButtonNew").Click
logPassFail err,"ButtonNew"
end if


'In the library file
'=============
Function WebApp_Exists(byref objEst,byval objName)

msgbox objEst.Image("ButtonNew").exist
    Dim CTRL_TYPES
        CTRL_TYPES = Array( "WebEdit" _
                  , "WebCheckBox" _
                  , "Image" _
                  , "WebButton" _
                  , "WinButton" _
                  , "WebElement" _
                  , "Link" _
                  , "WebRadioButton" _
                   , "WebRadioGroup" _
                  , "WebList" _
                   , "WebTable" _
                  )
        Dim iCount
  
   checkExistStatus = False

for iCount = 0 to Ubound( CTRL_TYPES)
             Dim ctrlType
             ctrlType = CTRL_TYPES(iCount)
             On Error Resume Next
             Err.Clear
   'ctrlType = "WebEdit"
  ' Set ExistStatus  = eval("objEst."& ctrlType&"(objName)")
    Set ExistStatus  = eval("objEst."&ctrlType&"(objName)")
      If  ExistStatus.Exist(0) Then
          checkExistStatus = True
          Exit Function
          else
          checkExistStatus = False
        End If
      Next

End Function