在做一个房屋管理系统时,我使用了DBNavigator1,和dbedit,我现在要单击DBNavigator1上的删除按钮后,调用一个过程,代码如下
procedure Tcontractform.deleterecord_rtable;
var
times,per,i:integer;
{times:租期,per:付款期限}
starttime,day,temps:widestring;
//location:string;
begin
//location:=0;
with datacontrls.ctable do
begin
open;//要相对表进行操作必训县打开数据表
edit; //进入编辑状态
per:=0;
times:=0;
times:=strtoint(trim(dbedit4.text));// 租期字段
temps:=trim(dbedit6.text);//付款期限字段
if temps='ay' then
per:=1 //表明是1个月交一次
else if temps='aj' then
per:=3 //表明三个月交一次
else if temps='bn' then
per:=6 //表明六个月交一次
else if temps='an' then
per:=12; //表明12个月交一次
//starttime:=trim(dbedit5.text);//起租日期
//year:=strtoint(copy(starttime,1,4));
//month:=strtoint(copy(starttime,5,2));
//day:=copy(starttime,7,2); //用字符串处理函数会更好一些 //以下判断什么时候交钱这个算法是最难的 for i:=0 to (times*12 div per)-1 do //这里的循环条件想实现的功能是判断一下一年要交几次费用书中程序里没有让times乘12是不对的
begin
datacontrls.rtable.Open;
datacontrls.rTable.Locate('contractid',dbedit1.text,[]);
with datacontrls.RTable do
begin
delete;
post;
end;
end;
end;
end;
当我调用以上代码时,总告诉我有一个无效的整数值,刚开始学delphi请大家帮帮我。三棵(thank)。
procedure Tcontractform.deleterecord_rtable;
var
times,per,i:integer;
{times:租期,per:付款期限}
starttime,day,temps:widestring;
//location:string;
begin
//location:=0;
with datacontrls.ctable do
begin
open;//要相对表进行操作必训县打开数据表
edit; //进入编辑状态
per:=0;
times:=0;
times:=strtoint(trim(dbedit4.text));// 租期字段
temps:=trim(dbedit6.text);//付款期限字段
if temps='ay' then
per:=1 //表明是1个月交一次
else if temps='aj' then
per:=3 //表明三个月交一次
else if temps='bn' then
per:=6 //表明六个月交一次
else if temps='an' then
per:=12; //表明12个月交一次
//starttime:=trim(dbedit5.text);//起租日期
//year:=strtoint(copy(starttime,1,4));
//month:=strtoint(copy(starttime,5,2));
//day:=copy(starttime,7,2); //用字符串处理函数会更好一些 //以下判断什么时候交钱这个算法是最难的 for i:=0 to (times*12 div per)-1 do //这里的循环条件想实现的功能是判断一下一年要交几次费用书中程序里没有让times乘12是不对的
begin
datacontrls.rtable.Open;
datacontrls.rTable.Locate('contractid',dbedit1.text,[]);
with datacontrls.RTable do
begin
delete;
post;
end;
end;
end;
end;
当我调用以上代码时,总告诉我有一个无效的整数值,刚开始学delphi请大家帮帮我。三棵(thank)。
可能之前区分了大小写。
如果是空值就不能转换了,或者非法的值也是有问题的