我跟踪了!
它是在过程退出的时候,就是执行end的时候出错的!
我应该怎样修改?
你说可能有些对象是没有创建就使用造成的?附源代码:
unit icuser_chongzhi;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, DBGrids, Db, DBTables DBTables;
type
Tic_user_chongzhi = class(TForm)
GroupBox2: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button3: TButton;
Edit3: TEdit;
Label4: TLabel;
Button2: TButton;
Label10: TLabel;
GroupBox3: TGroupBox;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
Edit18: TEdit;
Button4: TButton;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
Edit14: TEdit;
Edit15: TEdit;
Edit16: TEdit;
Edit17: TEdit;
Edit19: TEdit;
DataSource1: TDataSource;
Table1: TTable;
DBGrid1: TDBGrid;
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
//icdev:longint;
st:smallint;
end;
var
ic_user_chongzhi: Tic_user_chongzhi;
function IC_Read(icdev:longint;offset:smallint;len:smallint;databuff
char):smallint;stdcall;far;external 'DCIC32.DLL' name 'IC_Read';
function IC_Write(icdev: longint;offset:smallint;len:smallint;databuff
char):smallint;stdcall;far;external 'DCIC32.DLL' name 'IC_Write';
implementation
uses main;
{$R *.DFM}
procedure Tic_user_chongzhi.Button2Click(Sender: TObject);
begin
close;
mainform.ic8.Enabled:=true;
end;
procedure Tic_user_chongzhi.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
action:=cafree;
end;
procedure Tic_user_chongzhi.Button4Click(Sender: TObject);
var
receive_data
char;
begin
//学号
st:=IC_Read(mainform.icdev,33,20,receive_data);
if st=0 then
begin
receive_data[20]:=#0;
edit11.text:=strpas(receive_data);
end;
//性别
st:=IC_Read(mainform.icdev,53,2,receive_data);
if st=0 then
begin
receive_data[2]:=#0;
edit13.text:=strpas(receive_data);
end;
//姓名
st:=IC_Read(mainform.icdev,55,10,receive_data);
if st=0 then
begin
receive_data[10]:=#0;
edit12.text:=strpas(receive_data);
end;
//班级
st:=IC_Read(mainform.icdev,65,20,receive_data);
if st=0 then
begin
receive_data[20]:=#0;
edit14.text:=strpas(receive_data);
end;
//部门
st:=IC_Read(mainform.icdev,85,20,receive_data);
if st=0 then
begin
receive_data[20]:=#0;
edit15.text:=strpas(receive_data);
end;
//余额
st:=IC_Read(mainform.icdev,135,10,receive_data);
if st=0 then
begin
receive_data[10]:=#0;
edit1.text:=strpas(receive_data);
end;
//最后上机时间
st:=IC_Read(mainform.icdev,145,10,receive_data);
if st=0 then
begin
receive_data[10]:=#0;
edit16.text:=strpas(receive_data);
end;
//挂失标志
st:=IC_Read(mainform.icdev,155,10,receive_data);
if st=0 then
begin
receive_data[10]:=#0;
edit17.text:=strpas(receive_data)+'次';
end;
// edit2.SetFocus;
// button3.Enabled:=true;
end;(((((((就是退出这里的时候出错!究竟我有哪些对象没有创建就直接使用了?)))))))
procedure Tic_user_chongzhi.Button3Click(Sender: TObject);
var
total_money:string;
mima
char;
begin
//检查写入的数据
if edit2.text='' then
begin
showmessage('充值金额难道为空?');
exit;
end;
//检查写入的数据结束
{ st:=IC_Status(mainform.icdev);
if st<>0 then
begin
showmessage('请插入卡!然后点击确定!');
end; }
//先计算余额
total_money:=inttostr(strtoint(edit1.Text)+strtoint(edit2.Text));
//开始写卡
st:=IC_Write(mainform.icdev,135,10,pchar(total_money));
if st<0 then
begin
showmessage('写入余额失败!');
exit;
end;
if table1.Locate('学号',edit11.text,[]) then
begin
table1.Edit;
table1.FieldByName('余额').asstring:=total_money;
table1.Post;
end;
showmessage('写余额成功,请换下一张卡!');
//写卡结束
st:=IC_Down(mainform.icdev);
if st<0 then
begin
showmessage('IC卡下电错误!');
exit;
end;
button3.Enabled:=false;
end;
end.