VB6-inaccessible object wrapper

Source: Internet
Author: User

Take a look at the followingCode:

' Interface command
Public   Sub   Execute (): End sub

' Testcommand
Implements vb6dpframework. Command

Public Count As   Integer

Private   Sub Command_execute ()
Count =   1
End sub

' Commandwrapper
Private Mself As Testcommand

Private Minterface As Vb6dpframework. Command

Public   Sub Dispose ()
Set Mself =   Nothing
Set Minterface =   Nothing
End sub

Public   Sub Instance ()
If Minterface Is   Nothing   Then
Set Minterface =   New Testcommand
Set Mself = Minterface
End   If
End sub

Public   Function Interface () As Vb6dpframework. Command
Instance
Set Interface = Minterface
End Function

Public   Function Self () As Testcommand
Instance
Set Self = Mself
End Function

' Testcase
Public   Sub Test_wrapper (otestresult As Testresult)
With Otestresult
Dim W As   New Commandwrapper
W. interface. Execute
. Assertequalslong W. Self. Count, 1
Set W =   Nothing
End   With
End sub

Testcommand inherits the command interface.
The dim t as command method cannot access the Count attribute.
If
The dim t as testcommand method cannot access the execute method.

This makes it difficult to use. Of course, if you implement a public execute in testcommand, you can declare multiple objects and assign values, to solve this problem, using commandwrapper may be a good choice, at least better.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.