|
An array is a list of variables of the same type. Arrays are useful for organizing multiple variables. To create an array, use the DIM (dimension) command. The following example does not use arrays:
b = 4 c = 6 d = 8 e = 10 PRINT a, b, c, d, e
This uses an array called vars, which contains 5 variables:
' Each of these are separate variables: vars(1) = 2 vars(2) = 4 vars(3) = 6 vars(4) = 8 vars(5) = 10 PRINT vars(1), vars(2), vars(3), vars(4), vars(5)
![]() How an array of variables is stored in memory (NOTE: Memory addresses are not necessarily as specified) The above program can also be written like this:
FOR x = 1 to 5
FOR x = 1 to 5
Strings You can also create an array of string variables.
vars$(1) = "Two" vars$(2) = "Four" vars$(3) = "Six" vars$(4) = "Eight" vars$(5) = "Ten" PRINT vars$(1), vars$(2), vars$(3), vars$(4), vars$(5)
Feel free to distribute this tutorial, upload it to your website, link to it from your site, etc. http://www.geocities.com/progsharehouse/qbtutor Mirror: http://development.freeservers.com/qbtutor |