Autor Beitrag
mara_buh
Hält's aus hier
Beiträge: 8


Delphi 6
BeitragVerfasst: Fr 21.04.06 16:52 
Bei mir tritt immer der Fehler "inkompatible typen; 'Integer' und 'Extended'" und ich kann ihn nich beheben. Wäre toll, wenn mir jemand helfen könnte.

ps: Es ist noch nicht fertig. Möchte, dass wenn man auf den button klickt, sich ein neues formular öffnet und alle daten, die eingegeben und ausgerechnet wurden, darin stehen.

Quelltext:

ausblenden volle Höhe Delphi-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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    ComboBox1: TComboBox;
    Label1: TLabel;
    ComboBox2: TComboBox;
    Label2: TLabel;
    Label3: TLabel;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    CheckBox1: TCheckBox;
    Edit1: TEdit;
    Label4: TLabel;
    Label5: TLabel;
    Edit2: TEdit;
    CheckBox2: TCheckBox;
    Edit3: TEdit;
    Edit4: TEdit;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.Button3Click(Sender: TObject);
begin
close
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 edit1.clear  ;
 edit2.clear ;
 edit3.clear ;
 edit4.clear ;
end;

procedure TForm1.Button1Click(Sender: TObject);
var tarif, i, km, datum1, datum2, uhrzeit1, uhrzeit2, preis : integer;
begin datum1:=StrToInt(edit1.text);
      datum2:=StrToInt(edit3.text);
      uhrzeit1:=StrToInt(edit2.text);
      uhrzeit2:=StrToInt(edit4.text);
case combobox1.itemindex of
   0: tarif:=0.2 ;
   1: tarif:=0.5 ;
   2: tarif:=0.25 ;
end;
case combobox2.itemindex of
   0: km:=25 ;
   1: km:=50 ;
   2: km:=75 ;
   3: km:=100 ;
   4: km:=200 ;
   5: km:=500 ;
   6: km:=1000 ;
end;
i:=1   ;
repeat
    preis:=i*tarif     ;
    i:=i+1 ;
until i=km ;
showmessage('Ihre Reisedaten: Hinfahrt: am ' + IntToStr(datum1) + ' um ' + IntToStr(uhrzeit1) +
' Rückreise: am '  + IntToStr(datum2) + ' um ' + IntToStr(uhrzeit2));
end;

end.


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Fr 21.04.06 16:57 
Deklariere "tarif" als extended und nicht als integer, immerhin weist du der Variable Gleitkommazahlen zu.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 21.04.06 16:58 
Du versuchst irgendwo einem Integer einen Gleitkommazahl zuzuweisen oder umgekehrt. in welcher Zeile wird der Fehler angezeigt?

BTW. Verwende bitte den Delphi-Tag für Delphi-Sourcecode

[Edit: tarif ist vom typ integer und du weißt im z.B. 0.2 zu]

_________________
Markus Kinzler.
megaman7de
Hält's aus hier
Beiträge: 10

Win XP Prof.
Delphi 2005
BeitragVerfasst: Fr 21.04.06 17:36 
mit trunc(tarif)(schneidet ab) oder round(tarif) (rundet -->Banker's Round) kannst du Extended zu Integer machen...
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 21.04.06 17:40 
Besser wäre es aber sie asl extended zu deklarieren, sonst wäre ja seine Fallabfrage unnötig, weil er ja dann immer 0 zuweisen würde.

_________________
Markus Kinzler.
mara_buh Threadstarter
Hält's aus hier
Beiträge: 8


Delphi 6
BeitragVerfasst: Sa 22.04.06 08:15 
Vielen Dank für die zahlreiche Hilfe !! Problem gelöst!!