The list is unsorted with the values that come first second and third (100,200,300)
The list indicates the order of the values which is first,second or third.
The Row's are what I call the Keys of the Dictionary
The Values of the dictionary are values that are used in the list
(Since Row:200 has the smallest soonest Value:2) (based on newList) 2 is before 3.
The Value:3 in Row:100 is later then Value:2, that's why the output should be Row:200.
After Row:200 is resolved, the next output would be Row:300 and Row:100 is the last outputted value, but I only need output one result not all 3.
Keys are Rows
Values are Values
Output is the Key of Dictionary
Code:Public Module Program Public Sub Main(args() As String) 'This kinda works I guess Dim newList2 As New List(Of Byte)({1, 2, 3}) Dim ListOfValues2 As New Dictionary(Of Integer, Byte) ListOfValues2.Add(100, 3) ListOfValues2.Add(200, 2) ListOfValues2.Add(300, 1) Dim firstToProcessRow As Integer = 0 For Each value In newList2 For Each Row As KeyValuePair(Of Integer, Byte) In ListOfValues2 If ListOfValues2.ContainsKey(Row.Value) AndAlso ListOfValues2(Row.Value) = value OrElse Row.Key = 0 Then firstToProcessRow = Row.Key GoTo exitFor End If Next Next exitFor: Debug.WriteLine(firstToProcessRow) 'Output is 100 when it should be 200. End Sub End Module




Reply With Quote
