Windows Database Applications CIS 341 Chapter 11
Objectives Declare and reference collections Collection types Data Structures Object collection Items collection of a list box
Referencing Collection Items DsStoreSales1.Tables(“Stores”) DsStoreSales1.Tables(0)
Collection Class ArrayListContains, Insert, RemoveAt, and Sort BitArrayBoolean values CollectionBaseUsed for inheritance DictionaryBaseUsed for inheritance HashtableAdd, Remove QueueEnqueue, Dequeue, Peek SortedListAdd, Remove, and RemoveAt StackPush, Pop, Peek
Stacks mstkList.Push(strItem) strItem = mstkList.Peek() mstkList.Pop()
Queue mqueList.Enqueue(strItem) strItem = mqueList.Peek() mqueList.Dequeue()
Hash Tables Strkey = strItem.GetHashCode.ToString() mhshTable.Add(strKey, strItem) strItem = lstLanguages.SelectedItem.ToString() strKey = strItem.GetHashCode mhshTable.Remove(strKey) For Each strItem In mhshTable.Values lstLanguages.Items.Add(strItem) Next
Sorted List strKey = strItem.Substring(0,3) msrtList.Add(strKey, strItem) lstLanguages.Items.Clear() For each strItem in msrtList.Values lstLanguages.Items.Add(strItem) Next
Collection of Objects Dim objStudent As New Student(txtName.Text, CDec(txtGPA.Text)) mcolStudents.Add(strKey, objStudent) objStudent = CType(mcolStudents.Item(strKey), Student)