Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Collection behavior when adding a new item
Message
From
24/07/2006 11:35:34
 
 
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:
01139211
Views:
13
>The loCondition in the ForEach is not the same as the loCondition object..
>In the second case oDropDownCondition holds two references to the same object. Using :
>
>       For Each loX In oDropDownCondition
>           oApp.AddJavascriptMessage(loX(1))
>       Next
>
This is not a factor. If I do this, I end up in the same situation:
        Dim loCondition(2) As Object
        Dim loConditionResult(2) As Object

        loCondition(1) = "NoDBUsers"
        loCondition(2) = "NoEntity=" + oDashboard.nEntity.ToString
        oDropDownCondition.Add(loCondition)
        loCondition(1) = "NoDBUsers2"
        loCondition(2) = "NoEntity=" + oDashboard.nEntity.ToString
        oDropDownCondition.Add(loCondition)

        For Each loConditionResult In oDropDownCondition
            oApp.AddJavascriptMessage(loConditionResult(1))
        Next
The only way to have it ok is to have it like this:
        Dim loCondition(2) As Object

        loCondition(1) = "NoDBUsers"
        loCondition(2) = "NoEntity=" + oDashboard.nEntity.ToString
        oDropDownCondition.Add(loCondition)
        ReDim loCondition(2)
        loCondition(1) = "NoDBUsers2"
        loCondition(2) = "NoEntity=" + oDashboard.nEntity.ToString
        oDropDownCondition.Add(loCondition)

        For Each loCondition In oDropDownCondition
            oApp.AddJavascriptMessage(loCondition(1))
        Next
Note that I could have use loConditionResult for the For Each. It is not a factor in this situation. The only way to make it work is to ReDim loCondition everytime I need to add a new item. This is really weird.
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