Hi all
I'm trying to improve my application by using class modules for a more object-oriented approach...
So far, it went quite well, but I'm trying some more complicated stuff now, and there is some behaviour I don't understand. I hope someone can point out my mistakes...
I have a class module A, which has as private members (a.o.) two instances of class B objects. That all works fine. Then I added class module C, also with two private instances of class D objects.
In class C, I created a method that uses an instance of class A as a parameter. I found out that passing such an instance as parameter can be done only as Variant, and then re-setting it internally to the correct type.
So far so good, here's the code of the method:
Code:
'METHOD Compare Structured Boms
Public Sub Compare(UploadBoms As Variant)
Set m_Uploads = UploadBoms
Stop
If m_Uploads.m_Bom1.LastLine > m_Uploads.m_Bom2.LastLine Then
m_UploadsLastLine = m_Uploads.m_Bom1.LastLine
Else
m_UploadsLastLine = m_Uploads.m_Bom2.LastLine
End If
End Sub
m_Uploads is the private member in class C that contains the passed instance UploadBoms of class A. The m_Bom1 and m_Bom2 are the private instances of class D.
If I comment out the If-Then-Else lines, this method works. At the stop, I can inspect the locals-window for the active variables/objects. The m_Uploads object exists and has all expected members. In the Immediate window I can enter for instance:
?m_Uploads.m_Bom1.LastLine
and it gives me the expected result.
But when I don't comment out the If-Then-Else lines, I get an error at the If-line, "Compile Error: Method or data member not found", with the m_Bom1 highlighted. In the locals window, I can see that the m_Uploads is not yet initialized...
This member however worked perfectly when I commented out the lines and inspected the locals-window???
What am I doing wrong here?
Thanks in advance for any help...