Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 106 Computing Fundamentals II Chapter 71 “Indexing”

Similar presentations


Presentation on theme: "CS 106 Computing Fundamentals II Chapter 71 “Indexing”"— Presentation transcript:

1 CS 106 Computing Fundamentals II Chapter 71 “Indexing”
Herbert G. Mayer, PSU CS Status 7/24/2013 Initial content copied verbatim from CS 106 material developed by CS professors: Cynthia Brown & Robert Martin

2 Syllabus Indexing String Structure Indexing Listboxes
Some Useful Properties

3 Indexing Indexing is the process of selecting one of multiple elements from an aggregate datum: A typical aggregate data structure is the array or string The selection is called “indexing” In simpler languages, the index is an integer numeric value More sophisticated languages allow other index types The index range is contiguous, starting at 0 or 1 It’s like having an address where you need a house number as well as a street name Indexing often “cycles” through all contiguous items in a linear fashion, using a loop

4 String Structure A string in VBA can be variable length and has an internal structure Each character in the string also has a position number, also called an index The first character in a string however has index 1, etc String “This is a string.” has 17 characters, counting the blanks and period ‘.‘: T h i s a t r n g . 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

5 Indexing in Listboxes We used listboxes as a place to print information on a user form But they can also be used as a flexible way to store and access information The workbook called IndexListBox has examples of how to use these features One important fact: indexing in a listbox starts at 0 instead of 1

6 Some Useful Properties
lstName.Listcount is the number of items in list box lstName lstName( anIndex ) is the item in the listbox lstName with index anIndex lstName.ListIndex is the index of the selected item in the listbox

7 Demo: Index ListBox


Download ppt "CS 106 Computing Fundamentals II Chapter 71 “Indexing”"

Similar presentations


Ads by Google