Autor Beitrag
xan553
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Sa 13.01.07 20:08 
Hallo,

ich habe seit kurzem delphi und habe mich au glei drangesetzt und nen kleines rechnenprogramm gebastelt,
mit der addition und subtraktion geht alles, nur beim dividieren bringt mir das programm nen fehler,
Hier mal der quellcode:


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Button3Click(Sender: TObject);
Var
   zahl1, zahl2, ergebnis: Real;
begin
  zahl1 := StrToInt(Edit1.Text);
  zahl2 := StrToInt(Edit2.Text);
  ergebnis := zahl1 / zahl2;
  Label5.Caption := FloatToStr(ergebnis);
begin

end;

end.


und bei end. bringt er mir nen fehler:

[Error] Unit1.pas(70): ';' expected but '.' found
[Error] Unit1.pas(89): Declaration expected but end of file found
[Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit1.pas'

Mfg Xan

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 13.01.07 20:49 
Erstmal :welcome: hier im Forum!

user profile iconxan553 hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Button3Click(Sender: TObject);
Var
   zahl1, zahl2, ergebnis: Real;
begin
  zahl1 := StrToInt(Edit1.Text);
  zahl2 := StrToInt(Edit2.Text);
  ergebnis := zahl1 / zahl2;
  Label5.Caption := FloatToStr(ergebnis);
begin

end;

end.


und bei end. bringt er mir nen fehler:

[Error] Unit1.pas(70): ';' expected but '.' found
[Error] Unit1.pas(89): Declaration expected but end of file found
[Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit1.pas'[/delphi]

Das begin ist zuviel... Dazu gibts kein end...

Noch was nebenbei: Du musst prüfen, ob zahl2 Null ist, weil du ja durch Null nicht teilen kannst! Prüfst du nicht, gibt es einen Fehler...
xan553 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: So 14.01.07 21:09 
Erstmal danke für den herzlichen empfang und die aschnelle hilfe

Wie prüfe ich ob zahl 2 null ist?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 14.01.07 21:12 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
if zahl2 = 0 then
  ShowMessage('Division durch Null ist nicht möglich!')
else
begin
  // hier kann die Division durchgeführt werden
end;
xan553 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: So 14.01.07 21:32 
ok danke