I declare 2 ClassModules:
Class1
Public MyProp As Class2
Public Sub MyMethod(val As Class2)
Set MyProp = val
MsgBox MyProp.Foo
End Sub
Class2
Public Foo As String
Sheet1
Private Sub CommandButton1_Click()
Dim a As Class1
Dim b As Class2
Set a = New Class1
Set b = New Class2
b.Foo = "Bar"
a.MyMethod (b)
End Sub
When I call a.MyMethod (b), I get "Object doesn't support this property or method"
but if I write the code as following, everything works as expected:
Private Sub CommandButton1_Click()
Dim a As Variant
Dim b As Variant
Set a = New Class1
Set b = New Class2
b.Foo = "Bar"
a.MyMethod (b)
End Sub
What Am I doing wrong?