90 likes | 198 Vues
This chapter focuses on understanding collections in Windows database applications. It begins with the declaration and referencing of collections, followed by an in-depth look at various collection types and data structures. Key concepts include object collections, the use of list boxes to manipulate item collections, stacks, and queues for data organization, and hash tables for efficient item retrieval and storage. Practical examples illustrate adding, removing, and iterating over collection items, providing learners with a comprehensive understanding of how to utilize collections effectively within their applications.
E N D
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)
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)