Accessing an array | |||||||||||||||||||||||||||||||||||||
Once a array is defined you can start accessing it. Remember in order for a array to be useful you will need to store data into it at some point. This may be done through a user interface or done in code.
To change the a element in a array you use the assignment operator. For example to change the name "Fred" to "Fred Flintstone" we write the code Names(5) = "Fred Flintstone" We can access the contents of the array to display a test score for Sally simply by the code – MsgBox( test1(3) ) To find out what test "Bert" did best on we could write the code If test1(1) > test2(1) then Msgbox(names(1) + "did better on test 1") Else if test(1) < test2(1) then Msgbox(names(1) +"did better on test 2") Else Msgbox(names(1) + " did the same on both tests") End if In order to access a element in a array you simply put the name of the array and then the position you want to access.
|