計算機問題 |
|
apple0617
一般會員 發表:1 回覆:0 積分:0 註冊:2006-11-13 發送簡訊給我 |
要寫一個程式有11ㄍ案紐
上面是12345 下面是 -*/C 最後ㄉ暗紐是= 我在等於的地方寫不出來~執行後永遠都是只執行除ㄉ部份~ 請大家幫我看看我那錯ㄌ~謝謝 var Frm3134_2: TFrm3134_2; who: String; implementation {$R *.dfm} procedure TFrm3134_2.btn3134_21Click(Sender: TObject); begin if ( who = '1' ) then self.lbl3134_21.Text := self.lbl3134_21.Text '1' else self.lbl3134_22.Text := self.lbl3134_22.Text '1'; end; procedure TFrm3134_2.btn3134_22Click(Sender: TObject); begin if ( who = '1' ) then self.lbl3134_21.Text := self.lbl3134_21.Text '2' else self.lbl3134_22.Text := self.lbl3134_22.Text '2'; end; procedure TFrm3134_2.FormCreate(Sender: TObject); begin who := '1'; end; procedure TFrm3134_2.btn3134_23Click(Sender: TObject); begin if ( who = '1' ) then self.lbl3134_21.Text := self.lbl3134_21.Text '3' else self.lbl3134_22.Text := self.lbl3134_22.Text '3'; end; procedure TFrm3134_2.btn3134_24Click(Sender: TObject); begin if ( who = '1' ) then self.lbl3134_21.Text := self.lbl3134_21.Text '4' else self.lbl3134_22.Text := self.lbl3134_22.Text '4'; end; procedure TFrm3134_2.btn3134_25Click(Sender: TObject); begin if ( who = '1' ) then self.lbl3134_21.Text := self.lbl3134_21.Text '5' else self.lbl3134_22.Text := self.lbl3134_22.Text '5'; end; procedure TFrm3134_2.btn3134_26Click(Sender: TObject); begin who := '2'; self.txt3134_25.Caption := ' '; end; procedure TFrm3134_2.btn3134_27Click(Sender: TObject); begin who := '2'; self.txt3134_25.Caption := '-'; end; procedure TFrm3134_2.btn3134_28Click(Sender: TObject); begin who := '2'; self.txt3134_25.Caption := '*'; end; procedure TFrm3134_2.btn3134_29Click(Sender: TObject); begin who := '2'; self.txt3134_25.Caption := '/'; end; procedure TFrm3134_2.btn3134_210Click(Sender: TObject); begin if ( who = '1' ) then self.lbl3134_21.Text := self.lbl3134_21.Text '0' else self.lbl3134_22.Text := self.lbl3134_22.Text '0'; end; procedure TFrm3134_2.btn3134_211Click(Sender: TObject); begin if ( who = '6') then self.txt3134_25.Caption := ' '; self.lbl3134_23.Text := FloatToStr(StrToFloat(self.lbl3134_21.Text) StrToFloat(self.lbl3134_22.Text)); begin if (who = '3') then self.txt3134_25.Caption := '-'; self.lbl3134_23.Text := FloatToStr(StrToFloat(self.lbl3134_21.Text)-StrToFloat(self.lbl3134_22.Text)); begin if (who = '4') then self.txt3134_25.Caption := '*'; self.lbl3134_23.Text := FloatToStr(StrToFloat(self.lbl3134_21.Text)*StrToFloat(self.lbl3134_22.Text)); begin if (who = '5') then self.txt3134_25.Caption := '/'; self.lbl3134_23.Text := FloatToStr(StrToFloat(self.lbl3134_21.Text)/StrToFloat(self.lbl3134_22.Text)); end; end; end; end; end.
------
人仟 |
hsk6138
初階會員 發表:12 回覆:59 積分:49 註冊:2003-12-11 發送簡訊給我 |
我看不太懂你寫的 我寫一個簡易的1-4,+-*/=按鈕
解開你的移惑是我得成就 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Button5: TButton; Button6: TButton; Button7: TButton; Button8: TButton; Button9: TButton; Edit1: TEdit; procedure Button9Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; a,b:double; dd:string; implementation {$R *.dfm} procedure TForm1.Button9Click(Sender: TObject); begin case (Sender as Tbutton).Tag of 1..4:begin Edit1.Text:= Edit1.Text inttostr((Sender as Tbutton).Tag); end; 5..8:begin a:=strtofloat(Edit1.Text); Edit1.Text:=Edit1.Text (Sender as Tbutton).Caption; dd:=(Sender as Tbutton).Caption; end; 9:begin b:=strtofloat(copy(Edit1.Text,pos(dd,Edit1.Text) 1,length(Edit1.Text)- pos(dd,Edit1.Text))); case ord(dd[1]) of 43:Edit1.Text:=floattostr(a b); 45:Edit1.Text:=floattostr(a -b); 42:Edit1.Text:=floattostr(a *b); 47:Edit1.Text:=floattostr(a /b); end; a:=0; b:=0; dd:=' '; end; end; end; |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |