Arrays
Dim MyVariable As DataType = x
Dim StrName As String ="rach"
DimArray (5) As DataType
DimStrNames(2) As String
StrNames(0) = "rach"
StrNames(1) = "pam"
StrNames(2) = "david"
Declare and populate an array.
This means you can use as many or as little as you like.
Dim chMenu() As char ={"a","A","b"}
Loops
Dim intDinnerBooking(2) As Integer
->Dim strNames(2) As String
->Loop to populate
0 1 2
strNames "rach" "pam" "david"
0 1 2
intDinnerBookings 4 2 3
Dim ItemArray() As String = {"x","y","z"}
Dim intCount AsInteger
'declared a count integer
length is a property
length returns the number of elements not the upperbound.
For intCount= 0 To ItemArray.Length-1
lstbox.items.add(ItemArray(0)) 'this line of code is always going to return.
also requires a number even if zero 0
lstbox.items.add(ItemArray(intCount))
intCount can be used or declared as a varible
Next
listbox
intCount= 0 x
intCount=1 y
intCount=2 z
if no -1
the loop will count 4
The data in an array is often for an organized array
telephone directory is sorted by last name making this easier to search and locate family or friends.
When the sort procedure is applied to an array the lowest value is placed in the first element in th array with an index of zero the next lowst place is placed in the 2nd array and so on until the largest value is stored in the higher element of the array.
Dim intAges() as Integer ={16, 64, 41, 8, 19, 81, 23}
Array sort(intAges)
Binary search goes to the middle and starts search in the middle.
sort array
Sequential order
Dim loadsofNumbers (999) As integer
- populated
search for = 22
- sorted
0 - 1000
- binary search
500
if what you are searching for is less than then it dstroys.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment