Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic creation of class instances.
Message
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00479835
Message ID:
00483221
Views:
24
>>Say I have cEmployee class and I want to create another instance on the fly, how would I do that? Other than:
>>
>>Set oCEO as new cEmployee
>>Set oDeveloper as new cEmployee
>>Set oJanitor as new cEmployee
>>
>>Maybe a collection of custom class objects are what I need but I am not sure how to, or even if, that is the answer...
>
>For collection, you need a collection object and then you add your instances to the collection.
>
>Dim x as Collection
>Dim Y as cEmployee
>
>Set X = New Collection
>
>'Add a first employee
>Set Y = new cEmployee
>y. .... = ....
>y. .... = ....
>x.add y
>
>'Add a second employee
>Set Y = new cEmployee
>y. .... = ....
>y. .... = ....
>x.add y


Éric and group, I think I did not ask this question well. How, at run time, can I add a previously unknown employee? Is it possible to create a type of array with the class? Or is there another alternative. Using the above logic, Say at design time I only know in advance about a,b, and c and do the following:
Dim x as Collection
Dim a as cEmployee
Dim b as cEmployee
Dim c as cEmployee
x.add a
x.add b
x.add c

then during run time I need to add d to my collection? Or, more likely I might need to add the unknown at design time d,e,f,g,h etc.
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Previous
Next
Reply
Map
View

Click here to load this message in the networking platform