VBA class module not properly implementing Interface variant property

Viewed 88

I am trying to implement an interface that represents an abstraction of Tables in my VBA project, so that I can pass an array of the interface type into a function and display all tables, regardless of which subtype the table is. I am declaring some properties in the interface that all tables will have, but when trying to use an array as a interface member, I am getting the following error: Implementation Error

When I comment out both of the variant type members in the interface, the testing works fine.

Client
Got here
Scenario: test
Got there
(Client) got here

Here is my interface:

'Class name: IFScenarioTable
'Interface that generalizes all types of tables

' ----- INTERFACE MEMBERS ------
Public Scenario As String
Public ScenarioDetailsArray As Variant 'Array
Public TableLength As Integer
Public Result As ScenarioResult 'Custom class
'Public Tariffs As Variant 'Array


' ----- INTERFACE METHOD STUBS -----
Public Sub PrintInfo()

Here is one of the Classes that implements the interface:

Option Explicit
'Class name: PVScenarioTable
Implements IFST

'Variables for IFScenarioTable implementation
Private m_scenario As String
Private m_scenarioDetailsArray As Variant
Private m_tableLength As Integer
Private m_result As ScenarioResult
Private m_tariffs As Variant
'-----------------------------------------------------------------
'Implement IFScenarioTable variables

'scenario GET/SET
Property Let IFST_Scenario(ByVal Scenario As String)
    m_scenario = Scenario
End Property
Property Get IFST_Scenario() As String
    IFST_Scenario = m_scenario
End Property

'scenarioDetailsArray GET/SET
Property Let IFST_ScenarioDetailsArray(ByVal pScenarioDetailsArray As Variant)
    Set m_scenarioDetailsArray = pScenarioDetailsArray
End Property
Property Get IFST_ScenarioDetailsArray() As Variant
    IFST_ScenarioDetailsArray = m_scenarioDetailsArray
End Property

'tableLength GET/SET
Property Let IFST_TableLength(ByVal TableLength As Integer)
    m_tableLength = TableLength
End Property
Property Get IFST_TableLength() As Integer
    IFST_TableLength = m_tableLength
End Property

'result GET/SET
Property Set IFST_Result(ByVal Result As ScenarioResult)
    m_result = Result
End Property
Property Get IFST_Result() As ScenarioResult
    IFST_Result = m_result
End Property

'tariffs GET/SET
Property Let IFST_tariffs(ByVal Tariffs As Variant)
    Set m_tariffs = Tariffs
End Property
Property Get IFST_tariffs()
    IFST_tariffs = m_tariffs
End Property
'-----------------------------------------------------------------

'-----------------------------------------------------------------

'Implement methods
Public Sub Test()
    Debug.Print "test"
End Sub
'PrintInfo implementation
Public Sub IFST_PrintInfo()
    Debug.Print "Got here"
    Debug.Print "Scenario: " & m_scenario
    Debug.Print "Got there"
End Sub

And here is the client that tests the interface/class code:

Public Sub Client()
    Dim PVTable As PVScenarioTable
    Set PVTable = New PVScenarioTable
    With PVTable
        .IFST_Scenario = "test"
        .IFST_PrintInfo
    End With
    Debug.Print "(Client) got here"
End Sub
0 Answers
Related