Results 1 to 5 of 5

Thread: Urgent - Interface doesn't implement class

  1. #1

    Thread Starter
    Fanatic Member Mindcrime's Avatar
    Join Date
    Jun 2001
    Location
    Peterborough, UK
    Posts
    555

    Question Urgent - Interface doesn't implement class

    I have a Client set up in one VB app to use a object being run in a separate VB app.

    The client passes execution to the Interface, but the Class is never accessed. Could someone tell me why?

    Thanks in advance.

    This is the client code
    Code:
    Option Explicit
    Private Sub Command1_Click()
    Dim objComp As Object
    
        Set objComp = CreateObject("TSTestComp.IComp")
        
        Debug.Print objComp.Name
    End Sub
    This is the interface code being run separately called IComp. The instancing is set to MultiUse.
    Code:
    Property Get Name() As String
    '
    End Property
    Property Let Name(ByVal vNewValue As String)
    '
    End Property
    Property Get Version() As Variant
    '
    End Property
    Property Let Version(ByVal vNewValue As Variant)
    '
    End Property
    This is the class code being run separately called CComp.The instancing is set to PublicNotCreatable.
    Code:
    Implements IComp
    Private Name As String
    Private Property Let IComp_Name(ByVal RHS As String)
        Debug.Print "Hello World"
    End Property
    Private Property Get IComp_Name() As String
        Debug.Print "Hello World"
    End Property
    Private Property Let IComp_Version(ByVal RHS As Variant)
        Debug.Print "Hello World"
    End Property
    Private Property Get IComp_Version() As Variant
        Debug.Print "Hello World"
    End Property
    Mindcrime : )
    ICQ 24003332

    VB 5.0, VB 6.0 SP5, COM, DCOM, VB.NET Beta 2, Oracle 8

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Set objComp = CreateObject("TSTestComp.IComp")

    Because you re setting a reference to the interface, not the class that implements it. look at your CreateObject line ^^^
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Fanatic Member Mindcrime's Avatar
    Join Date
    Jun 2001
    Location
    Peterborough, UK
    Posts
    555
    Cander, thanks for the reply.

    I have hardly touched on COM before and I am being asked to do something in VB, which a C++ coder knows they can do (in C++).

    I could use referenced objects and code as follows:
    Code:
    Dim objCComp as CComp
    Dim objIComp as Icomp
    
        Set objCComp = new CComp
    
        Set objIComp = objCComp
    This would give me what I am after when using CreateObject. I don't know if it is possible.

    At the end of the day, the end application has to be as dynamic as possible.

    Regards
    Mindcrime : )
    ICQ 24003332

    VB 5.0, VB 6.0 SP5, COM, DCOM, VB.NET Beta 2, Oracle 8

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    But see there is no reason to do that. Just set you reference to the class the implements the interface. Since the class implements that interface, it's Type is considered to be that interface. there is no reason to create an instance of an interface, because interfaces have no code to run.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Just read your other post. Makes more sense now as to what you are doing. So nevermind the last thing I said. I wasnt taking into account the late binding Object.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width