これは、辞書にキーと値が既に含まれているかどうかを確認occurences
し、それにキーと値を割り当てる方法です...しかし、別の値が必要な場合、ここでオブジェクトを使用するにはどうすればよいですか?
Occurences.Add(xRows.Cells(4).Value.ToString(), Object)
どういうわけかこのように:
occurences(xRows.Cells(4).Value.ToString()) = Double.Parse(occurences(xRows.Cells(4).Value.ToString()).ToString()) + <"1st object value here">)
しかし、これは私が現在行っている方法で、キーと値しかありませんが、キー、(値、値) を持つオブジェクトのようなものが必要です。
実際のコード:
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
次に、オブジェクトの2番目の値を使用する必要がある挿入用の別のコードがあります。
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