Announcement

Collapse
No announcement yet.

COM Methods and Properties

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • COM Methods and Properties

    I am trying to convert a VB COM implementation of an activeX .OCX.

    The Method I am calling has some numeric values and an object as the argument.

    It returns an Object of which I need one of the properties.


    in VB:
    Code:
    PRIVATE SUB Command1_Click() ' VB example     
    
      DIM oGeneric AS Object
      
      SET oGeneric = CreateObject("MiscClass.Values")
      
      DIM oAnotherDefinedMethod AS Object ' 
                      
    
        
    ' CALL oGeneric( IN A AS SomeDefinedMethod, 
    '                IN B AS LONG, 
    '                IN C AS LONG, 
    '                IN D AS LONG) AS AnotherDefinedMethod
    
      SET oAnotherDefinedMethod = oGeneric.Values(Nothing, True, False, True)
      
      MSGBOX (oAnotherDefinedMethod.Count)
      
      SET oAnotherDefinedMethod = Nothing 
    
    END SUB
    My translation that will not compile
    Code:
        DIM oGeneric AS DISPATCH ' 
    
        LET oGeneric = NEW DISPATCH IN "MiscClass.Values" 
    
                            
        DIM vA AS VARIANT
        DIM vB AS VARIANT
        DIM vC AS VARIANT
        DIM oObj AS SomeDefinedMethod      ' OCX
        DIM oRet AS AnotherDefinedMethod   ' OCX
                   
                    
    ' CALL oGeneric( IN A AS SomeDefinedMethod, 
    '                IN B AS LONG, 
    '                IN C AS LONG, 
    '                IN D AS LONG) AS AnotherDefinedMethod
                                                         
    
        LET vA = 1                        
        LET vB = 0
        LET vC = 1     
        SET oObj  = NOTHING 
                                 '  Nothing,  True, False, True
        OBJECT CALL oGeneric.Values( oObj,    vA,    vB,    vC ) TO oRet  ' No Worky
      
        DIM vCount AS VARIANT      
        OBJECT GET oRet.Count TO vCount
                    
        DIM Count AS LONG
        Count = VARIANT#(vCount)
        MSGBOX STR$(Count)
          
        SET oGeneric = NOTHING
    In the generic case, how do you specify an object as an argument to a function call?
    In this case, how do you send NOTHING as an object argument?


    Actual:
    Member CALL Discovery<&H00000006>(IN A AS SomeDefinedMethod<&H00000000>, IN B AS LONG<&H00000001>, IN C AS LONG<&H00000002>, IN D AS LONG<&H00000003>) AS AnotherDefinedMethod
    Last edited by Mike Trader; 18 Oct 2007, 11:26 PM.
Working...
X