Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7656531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:47:16+00:00 2026-05-31T12:47:16+00:00

I have a challenge that I am trying to solve using classes. I am

  • 0

I have a challenge that I am trying to solve using classes.

I am logging transactions into a class.

Each transaction has the following:

  • Name
  • Date
  • Time
  • Description

However each transaction can also have many business related contacts with the following properties

  • Business Contact Name
  • Business Area
  • Percentage of Bill

Are there any examples of how this would be done.

I have tried adding a second class for the business contact and then building a collection inside the transaction class, all with no joy.

I have also tried making the business contact details a collection within the transaction class also with no joy.

Below is what I have so far, but i may have gone down a blind alley and it may not be worth trying to rescue the code

Any help much appreciated.

Thanks
JP


Test sub – trying to write the data in and get it back out

Sub test()

    Dim x As Integer
    Dim xx As Integer

    'code to populate some objects
    Dim clocklist As Collection
    Dim clock As classClocks
    Dim businesscontactlist As Collection
    Dim businesscontact As classBusinessContact

    Set businesscontactlist = New Collection
    Set clocklist = New Collection

    For x = 1 To 3
        Set clock = New classClocks
        clock.LawyerName = "lawyer " & Str(x)
        For xx = 1 To 3
            businesscontact.Name = "Business Contact " & Str(xx)
            businesscontactlist.Add businesscontact

        Next xx
        clock.BusinessContactAdd businesscontactlist '----- errors here
        clocklist.Add clock
    Next x

    Set businesscontactlist = Nothing

    'write the data backout again
    For Each clock In clocklist
        Debug.Print clock.LawyerName
        Set businesscontactlist = clock.BusinessContacts
        For Each businesscontact In businesscontactlist
            Debug.Print businesscontact.Name
        Next

    Next

End Sub

Clock Class – this is the transaction class

Private pLawyerName As String
Private pBusinessContactList As Collection

Public Property Get LawyerName() As String
    LawyerName = pLawyerName
End Property

Public Property Let LawyerName(ByVal sLawyerName As String)
    pLawyerName = sLawyerName
End Property

Public Property Get BusinessContacts() As Collection
    Set BusinessContacts = pBusinessContactList
End Property

Public Property Set BusinessContactAdd(ByRef strName() As Collection)
    Set pBusinessContactList = New Collection
    Dim businesscontact As classBusinessContact
    Set businesscontact = New classBusinessContact

    For Each businesscontact In strName
        businesscontact.Name = strName.Item()
        pBusinessContactList.Add businesscontact
    Next
End Property

Business contact Class – For the moment it only has one property

Private pBusinessContactName As String

Public Property Get Name() As String
    Name = pBusinessContactName
End Property

Public Property Let Name(ByVal sName As String)
    pBusinessContactName = sName
End Property
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:47:17+00:00Added an answer on May 31, 2026 at 12:47 pm

    There are a few things that don’t do what you expect in your code. I have cleaned it a bit and this new version should be closer to what you want. Let me know if the changes are not self-explanatory.

    Main procedure:

    Sub test()
    
        Dim i As Long
        Dim j As Long
    
        'code to populate some objects
        Dim clocklist As Collection
        Dim clock As classClocks
        Dim businessContactList As Collection
        Dim businessContact As classBusinessContact
    
        Set clocklist = New Collection
    
        For i = 1 To 3
            Set businessContactList = New Collection
            Set clock = New classClocks
            clock.LawyerName = "lawyer " & i
            For j = 1 To 3
                Set businessContact = New classBusinessContact
                businessContact.Name = "Business Contact " & j
                businessContactList.Add businessContact
            Next j
            Set clock.BusinessContactAdd = businessContactList
            clocklist.Add clock
        Next i
    
        Set businessContactList = Nothing
    
        'write the data backout again
        For Each clock In clocklist
            Debug.Print clock.LawyerName
            Set businessContactList = clock.BusinessContacts
            For Each businessContact In businessContactList
                Debug.Print businessContact.Name
            Next
    
        Next
    
    End Sub
    

    classClocks:

    Private pLawyerName As String
    Private pBusinessContactList As Collection
    
    Private Sub Class_Initialize()
      Set pBusinessContactList = New Collection
    End Sub
    
    Public Property Get LawyerName() As String
        LawyerName = pLawyerName
    End Property
    
    Public Property Let LawyerName(ByVal sLawyerName As String)
        pLawyerName = sLawyerName
    End Property
    
    Public Property Get BusinessContacts() As Collection
        Set BusinessContacts = pBusinessContactList
    End Property
    
    Public Property Set BusinessContactAdd(contactCollection As Collection)
    
        For Each contactName In contactCollection
            pBusinessContactList.Add contactName
        Next
    
    End Property
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a challenge that I am trying to solve and I can't work
I have a SQL challenge that is wracking my brain. I am trying to
I'm currently trying to dig deep into python and I have found a challenge
I'm trying to create a programming challenge that would require developers to hack into
I have a bit of web design that I’m trying to solve with efficient
i'm trying to write a program that solves the rsa challenge (yes i have
I have run into a challenge with a project - I am trying to
Challenge: I have this code that fails to compile. Can you figure out what's
I challenge you :) I have a process that someone already implemented. I will
I have been set a challenge to create an indexer that takes all words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.