Hallo,
also ich will ein programm erstellen, das 3 Zahlen die man zuvor in 3 verschiedenen Edit Feldern eingibt sortiert, diese sollen in 3 verschiedenen Panels ausgegeben werden.
Das Programm soll mit IF sätzen gemacht werden.
nun habe ich aber ein Problemm bei der Mittleren Zahl.
Die Größte und Kleinste Zahl ist kein probelm.
bitte um eine erklärung und einen Lösungsvorschlag wär sehr nett von euch wenn ihr mir helfen könntet den ich stehe total auf den schlauch.
falls ihr euch mein programm runterladen wollt ich hab es euch als anhang mit in das thema gemacht.
danke schonmal im vorraus und hier zeig ich euch nochmal meinen quelltext
mfg
martin tschapke
PS:
es wird folgende Fehlermeldung angezeigt:
Quelltext
1:
| [Fehler] Unit1.pas(82): Inkompatible Typen |
Quelltext:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls;
type TForm1 = class(TForm) Label1: TLabel; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Button1: TButton; Panel1: TPanel; Button2: TButton; Button3: TButton; Panel2: TPanel; Panel3: TPanel; Label2: TLabel; Label3: TLabel; procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button1Click(Sender: TObject); private public end;
var Form1: TForm1; Zahl1, Zahl2, Zahl3, klein, mittel, gross, nichts : INTEGER;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject); begin Form1.Close; end;
procedure TForm1.Button3Click(Sender: TObject); begin Form1.Edit1.Clear; Form1.Edit2.Clear; Form1.Edit3.Clear; Form1.Panel1.Caption := ''; Form1.Panel2.Caption := ''; Form1.Panel3.Caption := ''; Zahl1 := 0; Zahl2 := 0; Zahl3 := 0; klein := 0; gross := 0; mittel:= 0; end;
procedure TForm1.Button1Click(Sender: TObject); begin Zahl1 := StrToInt(Form1.Edit1.Text); Zahl2 := StrToInt(Form1.Edit2.Text); Zahl3 := StrToInt(Form1.Edit3.Text);
IF Zahl1 < Zahl2 THEN klein := Zahl1 else klein := Zahl2; IF klein > Zahl3 THEN klein := Zahl3;
IF Zahl1 > Zahl2 THEN gross := Zahl1 ELSE gross := Zahl2; IF gross < Zahl3 THEN gross := Zahl3;
IF Zahl1 > Zahl2 and Zahl1 < Zahl3 THEN mittel := Zahl1; IF Zahl1 > Zahl3 and Zahl1 < Zahl2 THEN mittel := Zahl1; IF Zahl2 > Zahl1 and Zahl2 < Zahl3 THEN mittel := Zahl2; IF Zahl2 > Zahl3 and Zahl2 < Zahl1 THEN mittel := Zahl2; IF Zahl3 > Zahl2 and Zahl3 < Zahl1 THEN mittel := Zahl3; IF Zahl3 > Zahl1 and Zahl3 < Zahl2 THEN mittel := Zahl3;
Form1.Panel1.Caption := IntToStr(klein); Form1.Panel2.Caption := IntToStr(mittel); Form1.Panel3.Caption := IntToStr(gross); end;
end. |
Moderiert von
Narses: Delphi-Tags hinzugefügt