Get key associated with max value in a Dictionnary using vb - without using LINQ?

Get key associated with max value in a Dictionnary using vb - without using LINQ?

Started learning Dictionary to deal with data from an engineering software. So far so good…
I am looking for a way of getting the max value in the dictionary and then get the key related to that max value. Dictionary (Of Integer, Double) representing (Node ID, value). According to the online doc it should be easy but it’s not working as I am getting an error message (specific to the eng. tool being used) when trying to run the test code.

Ultimately I’d like to return the "top N" Node ID corresponding to the "top N" value. It seems that this can be done easily with LINQ but as this cannot be done without an author license I am a bit stuck.

'The Remove method accepts only keys as arguments. To remove the “nth” item from a Dictionary object, use a workaround that uses the Remove and Keys methods:
myDictionary.Remove myDictionary.Keys()(maxvalue)

'AFTER
For Each pair In mydictionary
theLW.WriteLine(String.Format("{0}, {1}", pair.Key, pair.Value))
Next

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.The Tek-Tips staff will check this out and take appropriate action.