Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dealing with collections
Message
From
27/06/2010 16:12:38
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Dealing with collections
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01470724
Message ID:
01470724
Views:
101
I have a weird problem with a collection and I cannot find the reason. I am adding items in it from the first method and I am scanning its content from the second method.
    ' Add a distributor
    ' expN1 Distributor primary key
    ' expN2 Handling fee
    Private Function AddDistributor(ByVal tnNoDistributor As Integer, ByVal tnHandlingFee As Double) As Boolean
        Dim lnNoDistributor As Integer = 0
        Dim loObject(2) As Object

        ' See if it already exists
        For Each loObject In oDistributor
            lnNoDistributor = loObject(1)

            ' If this is the one
            If lnNoDistributor = tnNoDistributor Then
                Return True
            End If

        Next

        loObject(1) = tnNoDistributor
        loObject(2) = tnHandlingFee

        oDistributor.Add(loObject)
        Return True
    End Function

    ' Get the handling fee from the distributor collection
    Private Function GetHandlingFeeFromDistributorCollection() As Boolean
        Dim lnHandlingFee As Double = 0
        Dim loObject(2) As Object

        ' Reset the values
        nHandlingFee = 0

        ' For each item in the collection
        For Each loObject In oDistributor
            lnHandlingFee = loObject(2)

            nHandlingFee = nHandlingFee + lnHandlingFee
        Next

        Return True
    End Function
The problem is that the collection is built in duplicate with the same items. It should be different for each item I am adding in.
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
Next
Reply
Map
View

Click here to load this message in the networking platform