Can we return an object from a function
Hi,
Is there a way we can return an object to the calling function/sub from the called function?
For Ex:
//Called function
Function Test1(btnName)
Dim testObj
If btnName = "CLOSE" Then
Set testObj = Aliases.TMDS.WinFormsObject("frmBulletinHMI").FindChild("Name","WinFormsObject(""btnCloseTGBO"")", 5)
Test1 testObj
End If
End Function
//Calling sub
Sub Example
Dim test
Set test = test1("CLOSE")
test.click
End Sub
While running this scripts, I get the error:
Object doesn't support this property or method
Thanks,
Nimith
Got the solution!
You need to return as an object itself.
In the called function:
Set Test1 = testObj //while returning use the 'Set' keyword
In the calling function:
Set test = test1("CLOSE")
Thanks!