Talk:Array

From GDWiki

Jump to: navigation, search

[edit] Examples

Maybe this page should include examples on a variety of languages on simple routine functions. For example:

Dim a(1 To 5) As Byte 'Creates an array of bytes
Dim b() As Byte 'Creates an array of bytes that can be resized later

ReDim b(1 To 5) As Byte 'Resizes array b() to hold elements 1 to 5 (all data is lost without using Preserve)
b(3) = 10 'Sets element 3 in array b() to the value 10
ReDim Preserve b(1 to 10) 'Resizes the array, and keeps the data left in it

Dim c(1 to 5, 4 to 10) As Byte 'Creates a 2-dimensional array
Dim d() As Byte
 
ReDim d(1 to 2, 6 to 8) 'Resizes array d() to a 2-dimensional array
d(1, 7) = 10 'Sets the 2-dimensional array's value for element 1,7 to 10