Để một chương trình thử nghiệm sản xuất thực hiện tất cả các đường dẫn xấp xỉ cùng một số lần, chứ không phải thực hiện cùng một con đường lặp đi lặp lại. Tuy nhiên, thừa nhận rằng thời gian thử nghiệm có thể khá tốn kém, mục tiêu của một chương trình thử nghiệm sản xuất thường là như | 66 Excel Add-in Development in C C 8. Return the array Variant to VB from C C . 9. Return the array Variant to Excel from VB. The following sub-sections cover in more detail the various steps involved as well as providing more background information. Declaring VB arrays and passing them back to Excel VB arrays are fairly straightforward. They can be declared statically with statements such as these Dim integer_array 0 To 5 As Integer 6 elements zero-indexed Dim square_array 1 To 3 1 To 3 As Double 9 elts unit-indexed Dim variant_array 1 to 4 As Variant 4 Variant elts The Option Base statement at the top of the code module tells VB what the lower bound on an omitted array index should be for all arrays in that module. For example. Specify a default array lower bound of 1 Option Base 1 . then the array square_array above can equivalently but more readably be declared as follows Dim square_array 3 3 As Double 9 elements unit-indexed Arrays can also be declared without dimensions and then re-dimensioned dynamically later. A data type must be specified at declaration and cannot be changed. Here s an example Don t need to specify the number of or size of the dimensions Dim array As Double Allocate space for NumRows x NumCols elements ReDim array NumRows NumCols Arrays can be declared with up to 60 dimensions but for practical Excel add-in purposes 1 or 2 is usually all you need given the two-dimensional nature of Excel worksheets. Arrays are most easily returned to Excel as array Variants as shown in the following examples. The conversion from VB array to array Variant is implicit in the assignment of the array to the Variant return value. The type of the array elements is inherited from the data type of the VB array. Excel understands how to copy the contents of array Variants into the calling cell s . Note that these VB functions would need to be entered on the worksheet as array formulae. See section Array formulae - The Ctrl-Shift-Enter keystroke on page