Problem with Class module

  • Hi,

    I'm trying to create my first class module(s).

    First i got my Sub CreateClassCollection() routine in a regular module.
    It worked perfect

    Now i want to move it into the clQMProfileSequences class.

    I have 2 classes, one called clQMProfileSequence, containing the individual data and a class clQMProfileSequences, containing the collection of clQMProfileSequence.

    in a regular module i have following code on top before my subs:

    Option Explicit
    Option Private Module
    Public QualMarkProfile As clQMProfileSequences  'Declares QualMarkProfile as a clQMProfileSequences class

    I have also a userform with 3 buttons & a listbox.
    when i click on the 'Continue' button, following code is executed where i want to 'populate' the class collection:

    in my class module clQMProfileSequences (collection class module) i have following code:

    The problem i have is at the end where i Add the data to the QualMarkSequences.
    gives me following error message: Compile Error: Variable not defined

    Cause i'm new with Classes, i don't know what i'm doing wrong.

    the idea behind it is that i can use the properties and functions like:
    SequenceCount = QualMarkProfile.Count
    ProfileTime = QualMarkProfile.ProfileTime

    Anyone who can help me here?

    Best regards,

  • Re: Problem with Class module

    Quote from S O;724065

    Should it not be

    QualMarkProfile.Add ThisSeq

    instead? I don't see a "QualMarkSequences" declared anywhere?

    Thanks for your reply.

    I've also been looking around and this is what i have: my first working class module.

    First mistake was that i placed my declaration of the classes above the API declaration
    Changed it and needed to add the second class declaration too like:

    the Continue button has now following code

    and the class clQMProfileSequences has now following code in it

    It works now as desired.

    I know it's possible to put CreateClassCollection in the class initialize sub, but that's my next challenge.
    I'm already happy that this one works.

    Thanks for your remark, this was also a bug.

    Best regards,

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!