Today we completed the chapter 8 test.
An Array
If you have
Dim My Array(5) As DataType
this means that there is 6 elements.from 0 - 5
Dim strNames(2) As String... has 3 elements.
we assign a value to each value in the index - egs..
strNames(0) = "Rach"
strNames(1) = "Pam"
strNames(2) = "David"
Declare and populate an array
This way you can have as many or as little as you like this way.
Dim chMenuOptions() As Char = {"a", "A", "b"}
loops
Dim strNames(2) As String
Loop to populate
Another array
Dim intDinnerBookings(2) As integer
(in memory) there will be the 3 strings (strnames)
and the 3 integers (intDinnerBookings)
you can match things up via the index
Dim ItemArray (3) As String = {"x", "y", "3"}
Dim intCount As Integer - - we have declared a count integer
For intCount= 0 To ItemArray.Length - 1
lstBoxItems.Add(ItemArray(intCount))ine of code is always going to return.
Next
intCount = 0 -- x
intCount = 1 -- y
inCount = 2 -- z
length returns the number of elements, not the upperbound
sorting an array
the data in an array often is sorted for an organised display.
So could be alphebetical etc
egs. Array.Sort(strNames)
Searching an array
Sequential - is searching for each element in an array
BinarySearch - method searches a sorted array for a value using a binary search algorithm. The binary search algorithm searcehd an array by repeating dividing the search interval in half.
Sunday, August 9, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment