ITabRange.ToArray

Fore Syntax

ToArray: Array;

Fore.NET Syntax

ToArray(): System.Array;

Description

The ToArray method creates a two-dimension array. The array size is defined by the cell range size.

Comments

To transform range into two-dimension array of real values, use the ITabRange.ToDouble2DArray method.

Example

Executing the example requires a form that contains the Button component with the Button1 identifier, the TabSheetBox component with the TabSheetBox1 identifier and the UiTabSheet component with the UiTabSheet1 identifier. Set the UiTabSheet1 component as a data source for the TabSheetBox1 component.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    TSheet: ITabSheet;
    TRange: ITabRange;
    Arr: Array Of Variant;
    i, j: Integer;
Begin
    TSheet := UiTabSheet1.TabSheet;
    TRange := TSheet.View.Selection.Range;
    Arr := TRange.ToArray;
    i := Arr.GetUpperBound(1);
    j := Arr.GetUpperBound(2);
    Debug.WriteLine("Array dimensions: " + i.ToString + ", " + j.ToString);
End Sub Button1OnClick;

Clicking the button creates Arr array which contains values of the cells contained in selected table range. The variable "i" will contain the number of rows in the array, while the variable "j" contains the number of columns.

Fore.NET Example

The requirements and result of the Fore.NET Example execution match with those in the Fore Example. Use Fore.NET analogs instead of Fore components.

Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
    TSheet: ITabSheet;
    TRange: ITabRange;
    Arr: Array;
    i, j: Integer;
Begin
    TSheet := UiTabSheetNet1.TabSheetUi.TabSheet;
    TRange := TSheet.View.Selection.Range;
    Arr := TRange.ToArray();
    i := Arr.GetUpperBound(1);
    j := Arr.GetUpperBound(2);
    System.Diagnostics.Debug.WriteLine("Array dimensions: " + i.ToString + ", " + j.ToString);
End Sub;

See also:

ITabRange