Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

undecalre identifier VarArrayCreate

Status
Not open for further replies.

room24

Programmer
Dec 28, 2003
83
JM
when i compile my code below using delphi 6 i get this message
"undeclared identifier 'VarArrayCreate'"
can anyone explain please how can this be

here is the section of the code

procedure TfmChequeGrid.sbArrayClick(Sender: TObject);
{ declare array }
var
RowCount : integer;
count_index : integer;
CheckArray, excelapp, excelsht : variant;

begin
inherited;

CheckArray := VarArrayCreate([0,rowcount,0,8], varOleStr);
CheckArray[0,0] := 'Account';
CheckArray[0,1] := 'Ticker';
CheckArray[0,2] := 'Currency';
CheckArray[0,3] := 'Cheque Amount';
CheckArray[0,4] := 'Cheque Type';
CheckArray[0,5] := 'Status';
CheckArray[0,6] := 'Cheque Number';
CheckArray[0,7] := 'Cheque Date';

RowCount := quCheque.RecordCount;

quCheque.first;

while not quCheque.EOF do
begin
count_index := count_index + 1;

CheckArray[count_index,0] := quChequeAccountNameNumber.AsString;
CheckArray[count_index,1] := quChequeTicker.AsString;
CheckArray[count_index,2] := quChequeCurrency_name.AsString;
CheckArray[count_index,3] := quChequeCheque_amount.AsString;
CheckArray[count_index,4] := quChequeCheque_type.AsString;
CheckArray[count_index,5] := quChequeStatus.AsString;
CheckArray[count_index,6] := quChequeCheque_number.AsString;
CheckArray[count_index,7] := quChequeCheque_date.AsString;

quCheque.next;

end;
{initialize Excel }
excelapp := CreateOleObject('Excel.Application');
excelapp.Visible := False;
excelapp.Workbooks.Add;
excelsht := excelapp.WorkSheets.Item['Sheet1'];
excelsht.Activate;

{transfer entire array to spread sheet }

excelsht.Range[excelsht.Cells.Item[1,1],
excelsht.Cells.Item[(count_index),8]].value := CheckArray;

{ save and close }

excelapp.displayalerts := False;
excelsht.SaveAs('C:\Sale.xls');
excelapp.WOrkbooks.CLose;
excelapp.quit;

end;

end.
 
Do you have the System unit listed in your Uses clause?

-Dell
 
this is my uses clause below

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, GRIDFORM, Db, DBTables, Menus, StdCtrls, Grids, DBGrids, Buttons, ExtCtrls, ComObj, variants, ComCtrls;

i have included variants which solve the earlier problem with varArrayCreate but now when i compile i get it complains about "CreateOleObject" so now i have included
ComObj but it is now complaining about
identifier redeclared "ComObj"

help please
 
The "Identifier Redeclared" message appears if you have included a unit twice (either twice in one "uses" list, OR once in the interface "uses" list AND once in the implementation "uses" list). Check you have not done this. If you have then remove one of these appropriately i.e. if you need ComObj to enable you to declare anything in your interface section then leave it in the interface "uses" list, otherwise leave it in the implementation "uses" list.

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top