You can define your own variable type with code such as:
You can then declare a T_person type in your code with:
(*) I do not remember the details for declaring arrays in such circumstances. You might have to determine array's length when defining the variable. Please check help.
The same result can also be reached by declaring a class module named, for example, "Person". In this class module, you'll be not only able to follow the objet properties (such as name, dateOfBirth, etc), but also object events (initialisation and deletion). You'll be also able to create methods on this object. You code would then look like:
(*) Here, age is a calculated proerty of your object, available when dateOfBirth is not null. Please google "VBA class module" to find different examples for the implementation of a class module in VBA.
Now, if you want to manage a collection of similar "objects" (here, Persons), you will have to go through the creation of a class module for your objects collection (a "Persons" class module for example) and make use of the "Collection" objet available in VBA. You will then end with 2 different class modules: Person (will hold each person's detail), and Persons (will hold the collection of Persons). You'll then be able to have code like this:
Please google on "VBA collection object" for examples on Collection management in VBA. Check my code proposal, as this was written on the fly, and without VBA help file.
The "Class" solution is clearly more powerfull, but more complex than the "Type". Go for it if you need it. It is definitely worth the pain!
PS: I am not very happy with my namings here, as this can lead to very confusing code when dealing with the myPersons collection and myPerson instance of o Person object. I'd advise you to find a more obvious one, like "PersonCollection" and "Person", or even "Individual"
answered Feb 4 '10 at 3:53
9,97522 gold badges2323 silver badges6363 bronze badges
- Should Walmart buy Jet com
- What referral marketing system does Uber use
- What is your view on felon voting
- Is CNG good for Tata Tiago
- Who should invest in PPF
- Whats your favorite SciFi Space movie
- How many prisoners are falsely accused
- What do you think of LuHan
- How is Viber advertised
- How are women treated in Ecuador
- Are most sociopaths psychopaths gifted writers poets
- What places should I avoid in Cancun
- Is Grillinctus syrup safe for diabetics
- Why is inductive reasoning called deductive reasoning
- What skills would my hitman character need
- How would you rate the movie Risen
- How do people become dysfunctional
- What are some cycling workouts for beginners