SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 2 of 2
  1. #1
    Senior Member
    Join Date
    Jul 2008
    Posts
    212
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to pass in an object to class?

    I have a class in vbs like this:

    Code:


    Public Function New_Test123
    Set New_Test123=New Test123
    End Function

    Class Test123
    Private MyObject
    Public Property Let SetObj(objReport)
    MyObject=objReport
    End Property
    End Class



    And in my script:
    Code:


    Set MyScript=New_Test123()
    With MyScript
    .SetObj=Browser("").Page("").WebEdit("")
    End With



    QTP complains "Object doesn't support this property or method: 'MyObject'"

  2. #2
    Advanced Member Anshoo Arora's Avatar
    Join Date
    Oct 2007
    Location
    New Delhi, India
    Posts
    635
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to pass in an object to class?

    You are missing the read-only property, and because its an object reference, you must use the 'Set' keyword:

    <font class="small">Code:</font><hr /><pre>
    Class Test123

    Private MyObject

    Public Property Let SetObj(objReport)
    Set MyObject = objReport
    End Property
    Public Property Get SetObj
    Set SetObj = MyObject
    End Property

    End Class

    Public Function New_Test123
    Set New_Test123=New Test123
    End Function


    Set MyScript=New_Test123

    With MyScript
    .SetObj = Browser("").Page("").WebEdit("")
    End With
    </pre><hr />
    Regards,

    Anshoo Arora
    Relevant Codes

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:20 AM.

Copyright BetaSoft Inc.