建edit1,edit2,button
在edit1.text:='(4+5)*6';
双击button 下面就是代码,,,代码简单,本人初学,希望可以帮到你,,
procedure TForm1.Button1Click(Sender: TObject);
var
sStr,fStr:string;
I,Pos1,pos2,uNum:Integer;
begin
Pos1:= 0;
pos2:= 0;
fStr:= '';
sStr:= '';
sStr:= Edt1.Text;
Pos1:= Pos(#40,sStr);
if Pos1 > 0 then
begin
pos2:= Pos(#41,sStr,Pos1);
fStr:= Copy(sStr,Pos1 + 1,pos2 - Pos1 - 1 );
if Length(fStr) = 3 then
begin
if fStr[2] = #43 then
begin
uNum:= StrToInt(fStr[1]) + StrToInt(fStr[3]);
end;
end;
if sStr[6] = #42 then
begin
uNum:= uNum * StrToInt(sStr[7]);
Edit2.Text:= IntToStr(uNum);
end;
end;
end;
谢谢,但这并不是我想要的,我要的是可以计算自由输入不同式子的