Autor Beitrag
Phillipp
Hält's aus hier
Beiträge: 1



BeitragVerfasst: So 15.01.06 19:39 
Hallo. Ich habe für die Schule ein Programm rausgesucht und soll es an Hand des Codes erklären.

Es ist ein Programm das DM in Euro umrechnet.

Kann mir jemand folgenden Code bitte erklären?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.Edit1Change(Sender: TObject);
  var x,y:real;
begin
 if not edit1.Focused then exit;
 try
   x:=strToFloat(edit1.text);
   y:=1.95583*x;
   edit2.text:=formatfloat('0.##',y);
 except edit2.text:='' End;
end;
procedure TForm1.Edit2Change(Sender: TObject);
  var x,y:real;
begin
 if not edit2.Focused then exit;
 try
   y:=strToFloat(edit2.text);
   x:=1/1.95583*y;
   edit1.text:=formatfloat('0.##',x);
 except edit1.text:='' End;
end;


Also ich weiß was strToFloat,1.95583,edit2.text und real. Aber wofür steht formatfloat z.b?

Bitte um schnelle Antwort.



Gruß und tausend Dank
Phillipp

Moderiert von user profile iconGausi: Beitragsformatierung überarbeitet.


Zuletzt bearbeitet von Phillipp am So 15.01.06 19:44, insgesamt 1-mal bearbeitet
MadDoctor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 88

Win XP Pro
Delphie 2005
BeitragVerfasst: So 15.01.06 19:41 
Könntest du dich evtl. bemühen Delphie Tags zu benutzen ?

//Edit//
Danke Gausi !

_________________
Grüße an alle Grevener [NRW]
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 15.01.06 19:45 
Hallo und :welcome: in der Entwickler-Ecke!

Das mit den Delphi-Tags geht schon klar, hab die mal eingefügt. Was die bringen, sieht man ja wohl sofort.

Zu deinem Problem: Tipp mal in Delphi formatfloat ein, geh mit dem Textcursor in dieses Wort, und drück F1. Da steht dann alles.

_________________
We are, we were and will not be.
MadDoctor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 88

Win XP Pro
Delphie 2005
BeitragVerfasst: So 15.01.06 19:50 
Könntest aber auch die Forums Interne Suche Benutzen

Dort wirt dir recht schnell auffallen das das die Formation von Zahlen mit Nachkommastellen beeinträchtigt ;)

[Etwas Später]
Ob Tausender Punkte verwendet werden oder wie viele Nachkomastellen angezeigt werden sollen !

[Noch Etwas Später]
In deinem Fall:
ausblenden Delphi-Quelltext
1:
2:
3:
{...}   
  edit2.text:=formatfloat('0.##',y);
{...}

Wird der Wert Y mit der Formation 0.## ausgegeben, also mit 2 Nachkommerstellen

_________________
Grüße an alle Grevener [NRW]
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 16.01.06 21:17 
Und etwas Früher oder Später, laut MadDoctor's Meinung hast Du es begriffen oder stempelst Delphi als Teufelswerk ab und lässt es.
Sorry Ich konnt es mir nicht verkneifen...
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Di 17.01.06 09:51 
@MadDoctor & Blackheart666: Ich verstehe echt nicht, wie man so einen "Neuen" begrüßen kann. :?

_________________
Ein Nutzer der Ecke ;-)
MadDoctor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 88

Win XP Pro
Delphie 2005
BeitragVerfasst: Di 17.01.06 17:05 
Nur weil ich nicht
Zitat:
Hallo und :welcome: in der Entwickler-Ecke!

geschrieben habe heißt das ja noch lange nicht das ich ihn schlecht begrüße !

[Etwas Später]
Und um erlich zu sein, ich achte selten bis garnicht auf die "Titel" von daher ist mir auch nicht bewusst gewessen das er "Neu" ist !

_________________
Grüße an alle Grevener [NRW]