A
a_pess
' i face the following problem while using different types of system
collection classes
while using Hashtables as shown in the example below, the week days
will be shown in combobox1 start with "Wed"
and will start with "Sat" while using Stack and other collections are
ok
I wonder if i miss something here, or what is going on Exactly
i.am using VS2008 if that help
-----------------------------------------
Case 1 - Hashtable
'
' Create a new Hashtable.
Dim Hweeks As New Hashtable()
' Add some elements to the Hashtable
Hweeks.Add("1", "Sun")
Hweeks.Add("2", "Mon")
Hweeks.Add("3", "Tue")
Hweeks.Add("4", "Wed")
Hweeks.Add("5", "Thu")
Hweeks.Add("6", "Fri")
Hweeks.Add("7", "Sat")
'
' Create a new DictionaryEntry.
Dim Hday As DictionaryEntry
For Each Hday In Hweeks
ComboBox1.Items.Add(Hday.Value)
Next
' Case 2 - Stack
'
' Create a new Stack.
Dim stackTable As New Stack()
' Add some elements to the Stack
stackTable.Push("Sun")
stackTable.Push("Mon")
stackTable.Push("Tue")
stackTable.Push("Wed")
stackTable.Push("Thu")
stackTable.Push("Fri")
stackTable.Push("Sat")
For s As Integer = 0 To stackTable.Count - 1
ComboBox2.Items.Add(stackTable.ToArray(s))
Next
------------------------------------------------------------------------------------------
' Case 3 - Queue
'
' Create a new Queue.
Dim queueList As New Queue()
' Add some elements to the Queue
queueList.Enqueue("Sun")
queueList.Enqueue("Mon")
queueList.Enqueue("Tue")
queueList.Enqueue("Wed")
queueList.Enqueue("Thu")
queueList.Enqueue("Fri")
queueList.Enqueue("Sat")
For q As Integer = 0 To queueList.Count - 1
ComboBox3.Items.Add(queueList.ToArray(q))
Next
' Case 4 - ArrayList
'
' Create a new ArrayList.
Dim ItemList As New ArrayList()
' Add some elements to the ArrayList
ItemList.Add("Sun")
ItemList.Add("Mon")
ItemList.Add("Tue")
ItemList.Add("Wed")
ItemList.Add("Thu")
ItemList.Add("Fri")
ItemList.Add("Sat")
For a As Integer = 0 To ItemList.Count - 1
ComboBox4.Items.Add(ItemList.Item(a))
Next
' Case 5 - DictionaryOfString
'
' Create a new dictionary of strings.
Dim DictionaryOfString As New Dictionary(Of String, String)
' Add some elements to the dictionary.
DictionaryOfString.Add("1", "Sun")
DictionaryOfString.Add("2", "Mon")
DictionaryOfString.Add("3", "Tue")
DictionaryOfString.Add("4", "Wed")
DictionaryOfString.Add("5", "Thu")
DictionaryOfString.Add("6", "Fri")
DictionaryOfString.Add("7", "Sat")
For Each kvp As KeyValuePair(Of String, String) In
DictionaryOfString
ComboBox5.Items.Add(kvp.Value)
Next
' Case 6 - SortedList
'
' Creates and initializes a new SortedList.
Dim SL As New SortedList()
' Add some elements to the SortedList.
SL.Add("1", "Sun")
SL.Add("2", "Mon")
SL.Add("3", "Tue")
SL.Add("4", "Wed")
SL.Add("5", "Thu")
SL.Add("6", "Fri")
SL.Add("7", "Sat")
For l = 0 To SL.Count - 1
ComboBox6.Items.Add(SL.GetByIndex(l))
Next
thanks
Omar
collection classes
while using Hashtables as shown in the example below, the week days
will be shown in combobox1 start with "Wed"
and will start with "Sat" while using Stack and other collections are
ok
I wonder if i miss something here, or what is going on Exactly
i.am using VS2008 if that help
-----------------------------------------
Case 1 - Hashtable
'
' Create a new Hashtable.
Dim Hweeks As New Hashtable()
' Add some elements to the Hashtable
Hweeks.Add("1", "Sun")
Hweeks.Add("2", "Mon")
Hweeks.Add("3", "Tue")
Hweeks.Add("4", "Wed")
Hweeks.Add("5", "Thu")
Hweeks.Add("6", "Fri")
Hweeks.Add("7", "Sat")
'
' Create a new DictionaryEntry.
Dim Hday As DictionaryEntry
For Each Hday In Hweeks
ComboBox1.Items.Add(Hday.Value)
Next
' Case 2 - Stack
'
' Create a new Stack.
Dim stackTable As New Stack()
' Add some elements to the Stack
stackTable.Push("Sun")
stackTable.Push("Mon")
stackTable.Push("Tue")
stackTable.Push("Wed")
stackTable.Push("Thu")
stackTable.Push("Fri")
stackTable.Push("Sat")
For s As Integer = 0 To stackTable.Count - 1
ComboBox2.Items.Add(stackTable.ToArray(s))
Next
------------------------------------------------------------------------------------------
' Case 3 - Queue
'
' Create a new Queue.
Dim queueList As New Queue()
' Add some elements to the Queue
queueList.Enqueue("Sun")
queueList.Enqueue("Mon")
queueList.Enqueue("Tue")
queueList.Enqueue("Wed")
queueList.Enqueue("Thu")
queueList.Enqueue("Fri")
queueList.Enqueue("Sat")
For q As Integer = 0 To queueList.Count - 1
ComboBox3.Items.Add(queueList.ToArray(q))
Next
' Case 4 - ArrayList
'
' Create a new ArrayList.
Dim ItemList As New ArrayList()
' Add some elements to the ArrayList
ItemList.Add("Sun")
ItemList.Add("Mon")
ItemList.Add("Tue")
ItemList.Add("Wed")
ItemList.Add("Thu")
ItemList.Add("Fri")
ItemList.Add("Sat")
For a As Integer = 0 To ItemList.Count - 1
ComboBox4.Items.Add(ItemList.Item(a))
Next
' Case 5 - DictionaryOfString
'
' Create a new dictionary of strings.
Dim DictionaryOfString As New Dictionary(Of String, String)
' Add some elements to the dictionary.
DictionaryOfString.Add("1", "Sun")
DictionaryOfString.Add("2", "Mon")
DictionaryOfString.Add("3", "Tue")
DictionaryOfString.Add("4", "Wed")
DictionaryOfString.Add("5", "Thu")
DictionaryOfString.Add("6", "Fri")
DictionaryOfString.Add("7", "Sat")
For Each kvp As KeyValuePair(Of String, String) In
DictionaryOfString
ComboBox5.Items.Add(kvp.Value)
Next
' Case 6 - SortedList
'
' Creates and initializes a new SortedList.
Dim SL As New SortedList()
' Add some elements to the SortedList.
SL.Add("1", "Sun")
SL.Add("2", "Mon")
SL.Add("3", "Tue")
SL.Add("4", "Wed")
SL.Add("5", "Thu")
SL.Add("6", "Fri")
SL.Add("7", "Sat")
For l = 0 To SL.Count - 1
ComboBox6.Items.Add(SL.GetByIndex(l))
Next
thanks
Omar