User Tools

Site Tools


k7:k7.4:k7.4.3:k7.4.3.1:start

7.4.3.1 Native arrays

Gambas has a predefined array class for each native data type. The name of these classes is the name of the data type followed by an open and a closed square bracket:

Boolean[] 	Array of Boolean Values
Byte[] 	        Array of byte values
Short[] 	Array of short values
Integer[] 	Array of integer values
Long[] 	        Array of long values
Single[] 	Array of Single values
Float[] 	Array of Float values
Date[] 	        Array of Date values
String[] 	Array of string values
Object[] 	Array of Object values
Pointer[] 	Array of pointer values
Variant[] 	Array of Variant values

You can initialize an array or create an array within an expression with the[….Chapter 7.4.5 Inline Arrays.

Examples for the declaration of native arrays:

Dim myArray As New String[]
Dim myTable As New Float[10, 8]
Dim dArray As New Date[]
Dim aObjectArray As New Object[]

Example of using a native array:

  • Declaration of the variables aPlanets of type String array
  • Create an array object
  • Paste nine elements (data type string) into the string array using an inline array
  • Output of all elements of the array in the console of the Gambas IDE
Dim sElement As String
Dim aPlanets As String[]

aPlanetes = New String[]
aPlanetes = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"]

For Each sElement In aPlanetes
  Print sElement,
Next
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.
k7/k7.4/k7.4.3/k7.4.3.1/start.txt · Last modified: by 127.0.0.1