我现在有八个数值 工龄 年休
tNX1 1年 tYX1 5天tNX2 10年 10天 15年 15天
20年 20天。
我现在想要的结果是。当我edit1.text 为1-10之间时。年休为5天。当10-15为10天。15-20为15天。以此类推我用if (strtoint(edit1.Text)>Form_user.Tnx1) and (strtoint(edit1.Text)<Form_user.Tnx2) then begin
edit2.Text:=inttostr(Form_user.Tyx1);
end else begin
if (strtoint(edit1.Text)>Form_user.Tnx2) and (strtoint(edit1.Text)<Form_user.Tnx3) then begin
edit2.Text:=inttostr(Form_user.Tyx2);
end else begin
if (strtoint(edit1.Text)>Form_user.Tnx3) and (strtoint(edit1.Text)<Form_user.Tnx4) then begin
edit2.Text:=inttostr(Form_user.Tyx3);
end else begin
edit2.Text:=inttostr(FOrm_user.Tyx4);
tNX1 1年 tYX1 5天tNX2 10年 10天 15年 15天
20年 20天。
我现在想要的结果是。当我edit1.text 为1-10之间时。年休为5天。当10-15为10天。15-20为15天。以此类推我用if (strtoint(edit1.Text)>Form_user.Tnx1) and (strtoint(edit1.Text)<Form_user.Tnx2) then begin
edit2.Text:=inttostr(Form_user.Tyx1);
end else begin
if (strtoint(edit1.Text)>Form_user.Tnx2) and (strtoint(edit1.Text)<Form_user.Tnx3) then begin
edit2.Text:=inttostr(Form_user.Tyx2);
end else begin
if (strtoint(edit1.Text)>Form_user.Tnx3) and (strtoint(edit1.Text)<Form_user.Tnx4) then begin
edit2.Text:=inttostr(Form_user.Tyx3);
end else begin
edit2.Text:=inttostr(FOrm_user.Tyx4);
function GetDays(years:integer):integer;
begin
if (years>=1)and(years<=10) then
begin
result:=5;
exit;
end;
result:=years;
while (result mod 5)<>0 do
begin
inc(result);
end;
result:=result-5;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(inttostr(GetDays(strtoint(Edit1.Text))));
end;
挺好
就4个而已