2017年12月25日月曜日

vba動的array

VBAで配列のサイズを指定しないと、エラーとなる
Dim isholiday() As Boolean
isholiday(0) = checkHoliday(sWeek)

真ん中に、下記記述を入れるとOK
ReDim isholiday(endDate - startDate)

最初から以下のように指定してもNGだった
Dim isholiday(endDate - startDate) As Boolean

vba二次配列の範囲

33 x iの二次配列がある、iを取得するには、UBound(array(0))で試してみたが、エラーとなった。
UBound(array,2)でi-1の値を取得できた。

2017年12月12日火曜日

C# Array

int[] a1 = new int[10]; //10 elements
int[,] a2 = new int[10, 5]; //二次、50 (10 × 5) elements
int[,,] a3 = new int[10, 5, 2]; //三次、100 (10 × 5 × 2) elements

// An array with elements of an array type is sometimes called a jagged array because the lengths of the element arrays do not all have to be the same.
// creates an array with three elements, each of type int[] and each with an initial value of null
int[][] a = new int[3][];
a[0] = new int[10];
a[1] = new int[5];
a[2] = new int[20];

// allocates and initializes an int[] with three elements. the length of the array is inferred from the number of expressions between { and }
int[] a = new int[] {1, 2, 3};

// Local variable and field declarations can be shortened further such that the array type does not have to be restated
int[] a = {1, 2, 3};