Считать значения полей в вариантный массив
Автор: Xavier Pacheco
unit Main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DBTables, DB, StdCtrls, ExtCtrls, DBCtrls;
type
TForm1 = class(TForm)
Table1: TTable;
Button1: TButton;
Table1SpeciesNo: TFloatField;
Table1Category: TStringField;
Table1Common_Name: TStringField;
Table1SpeciesName: TStringField;
Table1Lengthcm: TFloatField;
Table1Length_In: TFloatField;
Table1Notes: TMemoField;
Table1Graphic: TGraphicField;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
const
AStr = 'The %s is of the %s category and its length is %f in.';
var
VarArr: Variant;
F: Double;
begin
VarArr := VarArrayCreate([0, 2], varVariant);
VarArr := Table1['Common_Name;Category;Length_In'];
F := VarArr[2];
ShowMessage(Format(AStr, [VarArr[0], VarArr[1], F]));
end;
end.
|