Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7885247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:00:45+00:00 2026-06-03T05:00:45+00:00

I declare my 2D lists: Dim _invoiceitems As New List(Of List(Of String)) Dim _dbitems

  • 0

I declare my 2D lists:

Dim _invoiceitems As New List(Of List(Of String))
Dim _dbitems As New List(Of List(Of String))

Each List is filled like this:

2D Lists Filled

Example Code To fill:

_invoiceitems.Add(New List(Of String))
_invoiceitems(0).Add("Code #")
_invoiceitems(0).Add("Quantity")

Well, now i need a third list called (_changesitems) Note that this result with the differences:
be the result of subtraction of quantities if this is found (dbitems – invoiceitems).

enter image description here

How i can get this result?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:00:46+00:00Added an answer on June 3, 2026 at 5:00 am

    The following code will generate the results you are looking for:

    Private Function getChangesItems(ByVal invoiceItems As Dictionary(Of String, Integer), ByVal dbItems As Dictionary(Of String, Integer)) As Dictionary(Of String, Integer)
        Dim changesItems As Dictionary(Of String, Integer) = New Dictionary(Of String, Integer)()
        Dim allCodes As List(Of String) = New List(Of String)()
        allCodes.AddRange(invoiceItems.Keys)
        allCodes.AddRange(dbItems.Keys)
        For Each code As String In allCodes
            If Not changesItems.ContainsKey(code) Then
                Dim dbQuantity As Integer = 0
                Dim invoiceQuantity As Integer = 0
                If dbItems.ContainsKey(code) Then
                    dbQuantity = dbItems(code)
                End If
                If invoiceItems.ContainsKey(code) Then
                    invoiceQuantity = invoiceItems(code)
                End If
                Dim changeQuantity As Integer = dbQuantity - invoiceQuantity
                If changeQuantity <> 0 Then
                    changesItems.Add(code, changeQuantity)
                End If
            End If
        Next
        Return changesItems
    End Function
    

    I used dictionaries instead of lists as was recommended by others. As long as your data only contains a code and a value, the dictionary is a better fit. If you have more columns, I would suggest creating a class that contains properties for each column and then make a list of that class type, rather than a simple 2D list of strings. Doing so would be more type-safe and easier to read.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is it possible to declare 2 array lists in the same line? e.g: List<String>
I have two lists declared as follows: Dim lstDBItems As New List(Of DBItem) Dim
Axiomatising the contains-operation on lists ( on Rise4Fun ) as (declare-fun Seq.in ((List Int)
I want to declare an empty list inside a scheme function. To make this
This is the code: Dim dr() As DataRow = DataSet.Tables(TableName).Select(EVENTNAME = ' & name
If I have a list: to_modify = [5,4,3,2,1,0] And then declare two other lists:
let's say you have set of integer in the list. List Declare: @lists =
I want to decare two Lists: First is a list of Integers. I decare
i want to declare a global linked list for a namespace in c#. i
I'm modifying some code that calls enumerate on a list declared via a list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.