Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Collection behavior when adding a new item
Message
From
24/07/2006 12:06:19
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01138855
Message ID:
01139228
Views:
16
>I didn't say my example fixed anything - just made plainer what the problem was. In your example below, if there is no ReDim(), you are still adding two *references* to the same loCondition object to the oDropDownCondition collection so obviously loCondition is pointing to the same object in both iterations of ForEach and thus loCondition(1) will be identical in both cases...
>
>Using Redim in your example creates a new loCondition object but the reference held in oDropDownCondition still points to the original instance.
>
>Try this:
>
>        Dim loCondition(2) As Object
>        loCondition(1) = "One"
>        loCondition(2) = "Two"
>        Dim oRef As Object = loCondition
>        ReDim loCondition(2)
>        loCondition(1) = "Three"
>        loCondition(2) = "Four"
>
>oRef will show the original ("One","Two"), loCondition the new ("Three,Four")

Well, if I have 20 conditions to add, is there a way to have one declaration for the object and reuse it? Basically, is there a way to clear its content before reassiging it again?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform