• Classes and referring to members of parent

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Classes and referring to members of parent

    Author
    Topic
    #461598

    I have three classes in a project: “StopPoint” contains a list of bus stops together with geocodes; “RouteLink” describes a route between two StopPoint objects referred to by the StopPoint ID at each end of the link; and “Service” which is a public transport service containing a collection of StopPoints and a collection of RouteLinks.

    The RouteLink class has a property, LinkDistance, which is read only and is calculated from the geocodes of the two StopPoints.

    What I am finding that I have to do is to store the geocodes of the StopPoints as part of the RouteLink in order to calculate the LinkDistance. This is because my class (or collection – not sure which) doesn’t seem to let me define a Parent method to return the Service class, which would allow me to refer back to the StopPoint collection. This leaves me having to store at least some of the the StopPoint information twice, which is unhelpful and inefficient. I’ve scratched my head, but I can’t see a sensible way to get around it. Can anyone help, please.

    Thanks.

    Viewing 1 reply thread
    Author
    Replies
    • #1172083

      I apologize, I fear that your question won’t get many replies here – the Lounge focuses on VBA within the Office applications. You may have better luck in one of the VB developer newsgroups.

    • #1172351

      What exactly do you mean when you say you can’t define a Parent for the RouteLink? Also, wouldn’t it be easier to assign a start and stop StopPoint object as properties of the RouteLink?

      • #1172445

        What exactly do you mean when you say you can’t define a Parent for the RouteLink? Also, wouldn’t it be easier to assign a start and stop StopPoint object as properties of the RouteLink?

        Yes. I realised eventually that that was all that I needed to do. I’m now revising my code to make it work properly! Thanks for the suggestion.

        As to the other reply, thanks – but actually I’m writing it inside Excel. It’s simply a part of other functions that I carry out with VBA to manage a complex data set. Perhaps in time I’ll port it to VB, but not yet.

        Regards,
        Stuart

    Viewing 1 reply thread
    Reply To: Classes and referring to members of parent

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: