delphi7 里 edit1 是输入两个自然数相乘要在 label1 里变成自然数+1再相乘怎么编写代码
2个回答
展开全部
呵呵我给你来一个最简单的吧!不过错误机制你要处理下哦!
觉得能用就给分吧谢谢
procedure TForm2.btn1Click(Sender: TObject);
var
str:string;
i,Temp1,Temp2 :Integer;
begin
str :=edt1.Text;
Temp1 :=0;
Temp2 :=0;
for I := 0 to Length(str)-1 do
begin
if (str[i] ='X') or (str[i] ='*') or(str[i] ='x') then
begin
Temp1 :=StrToInt(Copy(str,0,i-1));
Temp2 :=StrToInt(Copy(str,i+1,Length(str)-1));
Break;
end;
end;
lbl1.Caption := IntToStr((Temp1+1)*(Temp2+1));
end;
觉得能用就给分吧谢谢
procedure TForm2.btn1Click(Sender: TObject);
var
str:string;
i,Temp1,Temp2 :Integer;
begin
str :=edt1.Text;
Temp1 :=0;
Temp2 :=0;
for I := 0 to Length(str)-1 do
begin
if (str[i] ='X') or (str[i] ='*') or(str[i] ='x') then
begin
Temp1 :=StrToInt(Copy(str,0,i-1));
Temp2 :=StrToInt(Copy(str,i+1,Length(str)-1));
Break;
end;
end;
lbl1.Caption := IntToStr((Temp1+1)*(Temp2+1));
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询