Y
yybug
Unregistered / Unconfirmed
GUEST, unregistred user!
我的目的是想写一个导出数据的公共模块,可在^^^^^^^标记的地方,编译通不过。错误代码
写在后面了,望高手指教。
如果不写公共模块,导出语句可在程序中这样用,不出错:
ExportGrid4ToExcel('expGrid.xls',cxGrid1,True,True,False);
有错误的程序如下:
type
TSaveProcedure = Procedure (const AFileName: string; AGrid: TcxGrid; AExpand: Boolean; ASaveAll: Boolean ; AUseNativeFormat: Boolean) of object;
TInputGasForm = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Panel1: TPanel;
DateEdit1: TDateEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
......
procedure TInputGasForm.Save(ADefaultExt, AFilter, AFileName: String; AGrid:TcxGrid; AMethod: TSaveProcedure);
begin
with myDM.SaveDialog do
begin
DefaultExt := ADefaultExt;
Filter := AFilter;
FileName := AFileName;
if Execute then
AMethod(FileName, AGrid, True, True, False); /////////
end;
end;
procedure TInputGasForm.BitBtn5Click(Sender: TObject);
begin
Save('xml', 'XML File (*.xml)|*.xml', 'ExpGrid.xml', cxGrid1, ExportGrid4ToExcel);
end; ^^^^^^^^^^^^^^^^^^
[Error] InputGas.pas(206): Incompatible types: 'method pointer and regular procedure'
该如何修改?
写在后面了,望高手指教。
如果不写公共模块,导出语句可在程序中这样用,不出错:
ExportGrid4ToExcel('expGrid.xls',cxGrid1,True,True,False);
有错误的程序如下:
type
TSaveProcedure = Procedure (const AFileName: string; AGrid: TcxGrid; AExpand: Boolean; ASaveAll: Boolean ; AUseNativeFormat: Boolean) of object;
TInputGasForm = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Panel1: TPanel;
DateEdit1: TDateEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
......
procedure TInputGasForm.Save(ADefaultExt, AFilter, AFileName: String; AGrid:TcxGrid; AMethod: TSaveProcedure);
begin
with myDM.SaveDialog do
begin
DefaultExt := ADefaultExt;
Filter := AFilter;
FileName := AFileName;
if Execute then
AMethod(FileName, AGrid, True, True, False); /////////
end;
end;
procedure TInputGasForm.BitBtn5Click(Sender: TObject);
begin
Save('xml', 'XML File (*.xml)|*.xml', 'ExpGrid.xml', cxGrid1, ExportGrid4ToExcel);
end; ^^^^^^^^^^^^^^^^^^
[Error] InputGas.pas(206): Incompatible types: 'method pointer and regular procedure'
该如何修改?