Forum Discussion

kaiiii's avatar
kaiiii
Regular Contributor
5 years ago
Solved

Can we pass a Object in argument of a function.

CAn we pass an object as an argrument of a function that is declared in another unit.

like

Unit1:

'USEUNIT Unit2

Sub Task()

Set Obj = ............whatever here........

Call Validate(Obj)

End sub

 

Unit 2:

Function Validate(value)

Value.Click  'here I want to check properties for "value".... but getting errror "Object is required"

 

End Function

 

How can I pass object and use their properties in another unit. ?

6 Replies

    • kaiiii's avatar
      kaiiii
      Regular Contributor

      Hi Marsha_R Mars,

      Thanks for your reply.

      I had use Eval also for this  but It's not working.

       

  • Hi Kaiiii,

     

    how about defining a variable of the object type on project level or project suite level, using that to store your object and as parameter for your function Validate.

     

    Regards

    S_Seydel

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    The sceleton of your code looks correct.

    Most probably, as the text of the error says, object is not assignrd to the Obj variable and thus the code in the Validate() function cannot access object's properties.

     

    • kaiiii's avatar
      kaiiii
      Regular Contributor

      Marsha_R AlexKaras 

      Hi

      Thanks for your reply.

      It's solved now. actually Object id gets chnaged after every execution so I used objectlabel property.

      now it's working fine

      Thanks Marsha_R  for your suggestion.. it's working.