Autor Beitrag
Kia
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mo 06.11.06 19:33 
Hallo ich bräuchte mal kurz hilfe und zwar...

Hab ich ein Delphi-Formular erstellt das die Komponenten Edit1, Edit2 und Button1 enthält.
Wenn ich jetzt auf Button1 Clicke solll folgende Reaktion hervorgerufen werden:

Ist die Zahl in Edit1 größer oder gleich Null, so wird deren Wurzel berechnet und anschließend in Edit2 als Text ausgegeben. Andernfalls soll in Eidt2 eine Fehlermeldung ausgegben werden.

Ich hoffe ihr könnt mir helfen.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 06.11.06 19:35 
Wie sieht denn Dein bisheriger Ansatz aus und was funktioniert daran nicht?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Kia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mo 06.11.06 19:58 
ich krieg das mit dem code nich hin
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 06.11.06 19:59 
user profile iconKia hat folgendes geschrieben:
ich krieg das mit dem code nich hin

:lol: Das dachte ich mir auch...
Wo genau liegt dein Problem?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 06.11.06 20:01 
Dann zeig uns doch mal deinen Code! ;)

Zunächst einmal prüft du, ob die Zahl größergleich Null ist,
wenn ja, dann weiße deinem Edit2feld das Ergebnis aus der Wurzel deiner Zahl zu.
(Sqrt zieht die Wurzel aus einer Zahl - das Ergebnis ist Real). ;)
Ansonsten schreibst du deine Warnmeldung ins Edit2feld.
Fertig :)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
 Zahl: real;
begin
 ....
 if (Zahl >= 0)  then
  edit2.Text := FloatToStr( sqrt ( Zahl ));
   else
    edit2.Text := 'Achtung, Zahl kl. 0!';
end;

gruß
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Mo 06.11.06 20:03 
Manchmal hilft Pseudo-Code (also wenn man sich vorher überlegt, wie das Programm aussehen könnte):
ausblenden Quelltext
1:
2:
3:
4:
wenn Zahl >= 0 dann
  Edit2 = Wurzel(Zahl)
sonst
  Edit2 = "Zahl darf nicht negativ sein"

Und anschließend noch die Suche hier in der EE und bei Google: Suche in der Entwickler-Ecke WURZEL


EDIT: Oh Mann. Da versucht man mit Pseudo-Code zu helfen und derweil wird schon die Lösung in den Raum geschmissen.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Kia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Di 07.11.06 17:22 
habs danke !
georgfischerx
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 37



BeitragVerfasst: Do 09.11.06 20:12 
Titel: Titel: Quadratwurzel
Besuch doch mal meine Web-Seite --> www.quadratwurzel.ch .
Viel Spass !

Georg Fischer