Hallo und

im Forum!
Wie wäre es so:

Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
| procedure TForm1.BtnPlusClick(Sender: TObject); var a, b: Integer; begin if not TryStrToInt(EdPlus1.Text, a) or not TryStrToInt(EdPlus2.Text, b) then begin ShowMessage('Bitte nur Zahlen eingeben!'); Exit; end;
EdPlus3.Text := IntToStr(a + b); end; |
TryStrToInt gibt dir zurück ob die Umwandlung erfolgreich war und legt das Ergebnis in den zweiten Parameter.
Exit verlässt die aktuelle Schleife oder Prozedur, der Quelltext danach wird also nicht mehr ausgeführt (hier die Ergebnisanzeige).
Oder:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9:
| procedure TForm1.BtnPlusClick(Sender: TObject); var a, b: Integer; begin if TryStrToInt(EdPlus1.Text, a) and TryStrToInt(EdPlus2.Text, b) then EdPlus3.Text := IntToStr(a + b) else ShowMessage('Bitte nur Zahlen eingeben!'); end; |
// EDIT:
Vielleicht noch was zu deinem Code:
Killuminati91 hat folgendes geschrieben : |
Delphi-Quelltext 1: 2: 3:
| if a=Zahl then begin a:=StrToInt(EdPlus1.Text); | |
Du willst ja nicht schauen ob a eine Zahl ist, sondern ob in EdPlus1.Text eine Zahl drin steht.
In a ist bis dahin ja noch nichts drin.