くだすれDelphi(超初心者用)その25
■ このスレッドは過去ログ倉庫に格納されています
0775デフォルトの名無しさん
2005/07/03(日) 16:26:18すまない>>774は間違えた。
var
Atext : String;
Apos : Integer;
begin
Atext := Edit1.Text + Edit2.Text ;
//足すの場合
Apos := AnsiPos('+',AText);
if Apos <> 0 then
begin
result := StrToInt(copy(Atext,1,Apos-1)) + StrToInt(Copy(Atext,Apos+1,Length(Atext))) ;
Apos:=0;
end;
//かけるの場合
Apos := AnsiPos('*',AText);
if Apos <> 0 then
begin
result := StrToInt(copy(Atext,1,Apos-1)) * StrToInt(Copy(Atext,Apos+1,Length(Atext))) ;
Apos:=0;
end;
//引くと割るの場合は自分で考えてみよう。それと、TEdit.textの値が有効なものか事前にチェックする必要がある。
//やっていることは文字列を結合して、演算子を探して、演算子の前後を数値として演算子に応じて計算する。
end;
■ このスレッドは過去ログ倉庫に格納されています