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 8954997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:26:32+00:00 2026-06-15T14:26:32+00:00

This is how I Check if my dictionary occurences already contains a key and

  • 0

This is how I Check if my dictionary occurences already contains a key and a value and assign keys and values to it… but I need another value, so how do I use the object here?

Occurences.Add(xRows.Cells(4).Value.ToString(), Object)

Somehow like this:

occurences(xRows.Cells(4).Value.ToString()) = Double.Parse(occurences(xRows.Cells(4).Value.ToString()).ToString()) + <"1st object value here">)

But this is how I currently do it which only has a key and a value but I need something like key, object which has (value, value), something like that:

Actual code:

If (occurences.ContainsKey(xRows.Cells(4).Value.ToString())) Then
    occurences(xRows.Cells(4).Value.ToString()) = Double.Parse(occurences(xRows.Cells(4).Value.ToString()).ToString()) + Double.Parse(xRows.Cells(7).Value.ToString())
Else
    occurences.Add(xRows.Cells(4).Value.ToString(), Double.Parse(xRows.Cells(7).Value.ToString()))
End If

Next

Then i have another code for insert where i need to use the 2nd value of the object.

Using commm As New MySqlCommand()
    With commm
         .Parameters.Clear()
         .Parameters.AddWithValue("@iBrnchCde", cmbBrnchCode.Text)
         .Parameters.AddWithValue("@iFCode", pair.Key)
         .Parameters.AddWithValue("@iDesc", <"2nd OBJECT VALUE HERE"> )
         .Parameters.AddWithValue("@iQty", pair.Value)
         .CommandText = oInsertString
         .Connection = _conn
         .CommandType = CommandType.Text
     End With
     commm.ExecuteNonQuery()
End Using
  • 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-15T14:26:34+00:00Added an answer on June 15, 2026 at 2:26 pm

    Do the following:

    Class CustomRowObject
        Public Property Name() As String
        Public Property Quantity() As Double
        Public Property Description() As String
    End Class
    
    
    If (occurences.ContainsKey(xRows.Cells(4).Value.ToString())) Then
        occurences(xRows.Cells(4).Value.ToString()).Quantity = Double.Parse(occurences(xRows.Cells(4).Value.ToString()).ToString()) + Double.Parse(xRows.Cells(7).Value.ToString())
    Else
        occurences.Add(xRows.Cells(4).Value.ToString(),New CustomRowObject With { .Name = a.Cells("ProductName").Value.ToString(),.Description = .Cells("ProductDesc").Value.ToString(), .Quantity = a.Cells("Quantity").Value.ToString()})
    End If
    
    Next
    

    Then reference it via occurences("keynamegoeshere").Quantity for use in your SQL.

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

Sidebar

Related Questions

I am attempting to check a dictionary for existence of an item (both keys
Im trying to use a dictionary to check a given number of servers listed
I have this following piece of code to check an input against a dictionary
How do i check the key in dictionary is same as the string in
Occassionally I need to check for duplicate IDs in a set of values and
For instance, if dict['sample']: //append values to dict['sample'] else: // assign new key to
I am trying to read a value of a key from a dictionary like
I'm trying to use a dictionary. Whenever I want to check if an element
I need to check if a key exists and accordingly to an add or
This there a way to remove this check, when a user first accesses my

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.