ID : 583
CreateArray
Function
Create a single dimensional array of Variant type data with arbitrary Internal Processing Format.
Syntax
CreateArray(number of array elements [,internal processing format ])
Guaranteed entry
- Number of array elements
- Designate the number of array elements by Integer type data.
- Internal processing format
-
Specify the Internal processing format of array with Integer type data. This is an optional value. This should be “17” (byte type) if it is omitted. For each value against the Internal processing format, see Variant.h.
Return value
Return a single dimensional array with Variant.
Description
Create a single dimensional array of Variant type data with specified Internal processing format.
Assuming the argument number of array elements is n, the array Index number will be 0 to n-1.
To use constants defined by Variant.h in Internal processing format, embed Variant.h in #include.
Related Terms
Attention
-
Some Internal processing format defined by Variant.h cannot be used in CreateArray. If it is used, an error will occur at execution.
-
To create a double or more dimensional array, use CreateMultiArray.
Example
'!TITLE "CreateArray Sample Program"
' Example of creating data for binary communication
Sub Sample_CreateArray
Dim var As Variant
var = CreateArray(10)
var(0) = &ha2
var(1) = &hFF
var(2) = &h35
var(3) = &h3c
var(4) = &h7b
var(5) = &hFF
var(6) = &hFF
var(7) = &h45
var(8) = &h87
var(9) = &h99
Comm.Output 2,var
End Sub
'!TITLE "CreateArray sample program"
' Example of creating V-type variant
' from variant I[0],I[1] and I[2].
#include "Variant.h"
Sub Main
Dim var As Variant
var = CreateArray(3, VT_I4)
var(0) = I[0]
var(1) = I[1]
var(2) = I[2]
V[0] = var
End Sub
ID : 583