Esteemed Forum Participants and Lurkers:

NEWBIE Alert!

I finally got a primitive Dictionary working, but I need a Sorted version of the Dictionary.

VB Code:
  1. ' In myModule1 - straight out of the online VB.Net help
  2. Public Class DeviceDictionary
  3.         Inherits DictionaryBase
  4.  
  5.         Default Public Property Item(ByVal key As [String]) As [String]
  6.             Get
  7.                 Return CType(Dictionary(key), [String])
  8.             End Get
  9.             Set(ByVal Value As [String])
  10.                 Dictionary(key) = Value
  11.             End Set
  12.         End Property
  13.  
  14.         Public ReadOnly Property Keys() As ICollection
  15.             Get
  16.                 Return Dictionary.Keys
  17.             End Get
  18.         End Property
  19.  
  20.         Public ReadOnly Property Values() As ICollection
  21.             Get
  22.                 Return Dictionary.Values
  23.             End Get
  24.         End Property
  25.  
  26.         Public Sub Add(ByVal key As [String], ByVal value As [String])
  27.             Dictionary.Add(key, value)
  28.         End Sub 'Add
  29.  
  30.         Public Function Contains(ByVal key As [String]) As Boolean
  31.             Return Dictionary.Contains(key)
  32.         End Function 'Contains
  33.  
  34.         Public Sub Remove(ByVal key As [String])
  35.             Dictionary.Remove(key)
  36.         End Sub 'Remove
  37.     End Class
  38.  
  39. ' My Code ---
  40.     Public g_devlist As New DeviceDictionary
  41.     Dim myDE as DictionaryEntry
  42.  
  43. ....
  44.  
  45. ' Iterate through the DeviceDictionary
  46. For Each myDE in g_devlist
  47. ' Do my thing, but I need it in SORTED order!
  48. Next
This works great, except that I need to iterate through the Dictionary in SORTED order by key, and the default doesn't seem to do that. I couldn't find any ".Sort" help at all for Dictionary stuff.

My sincere appreciation for any comments, suggestions, or assistance.