Autor Beitrag
henny
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 126



BeitragVerfasst: Mi 27.05.09 10:52 
Ich möchte einen ganz einfachen Taschenrechner programmieren!
Wie mache ich das ?(Ich hab gerade erst das programmieren ein bisschen gelernt)
Könnte mir bitte wer helfen!
danke schonmal im voraus
gruß henny


Moderiert von user profile iconNarses: Topic aus Dateizugriff verschoben am Mi 27.05.2009 um 11:02
curtiss
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 59



BeitragVerfasst: Mi 27.05.09 10:57 
erstellt ne neue anwenudng, zeihst deine edit felder und buttons drauf, gibst den bezeichnungen wie + und - / usw. und packst die rechnungen dann zB. ins onClick ereignis. Fertig.
Bitte!
henny Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 126



BeitragVerfasst: Mi 27.05.09 11:13 
Ich habe das mal ausprobiert :
Als erstes ist ein edit dann 4buttons für die rechenart und dann noch mal ein edit.
Und am Schluss kommt noch ein label für das Ergebnis.
Aber wie muss ich das programmieren das wenn man z.B. auf + drückt das dann das ergebnis kommt?
nabbl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Mi 27.05.09 11:17 
Ich geh mal von 3 Edits aus:
Edit1: Operator 1
Edit2: Operator 2
Edit3: Ergebnis

So könnte ein Aufruf aussehen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
var a,b: Double;
begin
  // Text in eine Kommazahl wandeln
  a := StrToFloat(Edit1.Text);
  b := StrToFloat(Edit2.Text);
  // Kommazahl in Text wandeln
  Edit3.Text := FloatToStr(a+b);
end;
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mi 27.05.09 11:17 
mit StrToInt() kann mraan einen String in einen Integer verwandeln. Mit StrToIntDef() kann man sogar noch nen extraparameter mitgeben, welche zahl er nehmen soll wenn der String keine ganze Zahl war.

Mit der Operatoren "+","-","*","div" kann man wunderbar ganze Zahlen rechnen wenn man sie im Quelltext verwendet.

Mit IntToStr() kann man eine Integerzahl in einen String verwandeln.

So, mit dem Wissen müsstest du was anfangen können. ;) Wenn dem trotzdem nicht so ist, zieh Christian's Crashkurs zu rate, der hilft meistens bei anfängerproblemen.

//edit:
user profile iconhenny hat folgendes geschrieben Zum zitierten Posting springen:
Und am Schluss kommt noch ein label für das Ergebnis.


user profile iconnabbl hat folgendes geschrieben Zum zitierten Posting springen:
Ich geh mal von 3 Edits aus:


warum 3 edits? genauer lesen wäre angesagt ;)

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
nabbl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Mi 27.05.09 11:25 
Naja. Dann halt statt
ausblenden Delphi-Quelltext
1:
Edit3.Text := ...					

ein
ausblenden Delphi-Quelltext
1:
Label1.Caption := ...					


Ein bisschen Knobeln sollte er aber auch ;)
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mi 27.05.09 11:26 
user profile iconnabbl hat folgendes geschrieben Zum zitierten Posting springen:

Ein bisschen Knobeln sollte er aber auch ;)


deswegen hab ich auch nicht den ganzen lösungsweg hingeschrieben ;)

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
henny Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 126



BeitragVerfasst: Mi 27.05.09 11:35 
Mein button1 hat die aufschrift + und meine procedure sieht so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);
begin
ergebnis := zahl1 + zahl2;
label2.Caption := inttostr (ergebnis);
end;

end.

Aber das funkt. nicht muss ich da noch irgendwas machen?

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
nabbl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Mi 27.05.09 11:46 
lies dir mal meinen beitrag weiter oben durch...
henny Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 126



BeitragVerfasst: Mi 27.05.09 14:20 
Vielen dank für eure vielen beiträge ich habe es jetzt geschafft!