Autor Beitrag
lexmy3
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

WIN 2000 Prof. + Office 2000
Delphi 5 Enterprise
BeitragVerfasst: Do 09.03.06 09:58 
Hallo,

Habe diese Codes rausgefischt und diese machen das was ich möchte, jedoch wie mache ich das die Eingabe in das Edit2 übernommen wird??

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:
procedure TForm1.Edit2Exit(Sender: TObject);
var
  Betrag : Currency;

begin
     Betrag := Edit2.Text;// hier ist der Typen-Fehler???

  ThousandSeparator := ',';
  DecimalSeparator :='.';
  Edit2.Text :=(FloatToStrF(Betrag, ffCurrency, 10, 2));
end;

procedure TForm1.Edit2Change(Sender: TObject);
  function Filter(const S: String): String;
    const
      OK: Set of Char = ['0'..'9',',','.'] ;
    var
      i: Integer;
  begin
    Result := '';
    for i := 1 to Length(S) do
      if (S[i] in OK) then
        Result :=  Result +S[i];
  end;

begin
  if (Edit2.Modified) then
    Edit2.Text := Filter(Edit2.Text); // Eingabe bereinigen
    Edit2.SelStart := Length(Edit2.Text); // Cursor ans Textende stellen
    end;

END.

Fehler:
[Fehler] Unit1.pas(57): Inkompatible Typen: 'Currency' und 'TCaption'
mfg lexmy3
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Do 09.03.06 10:47 
Ein String ist doch keine Gleitkommazahl. Du musst den String doch erstmal umwandeln, so wie du es auch bei Edit2.test:=FloattoStrF(...); machst. Und da du genau das Gegenteil machen willst heißt der magische Befehl betrag:=StrToFloat(edit2.text);
lexmy3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

WIN 2000 Prof. + Office 2000
Delphi 5 Enterprise
BeitragVerfasst: Do 09.03.06 12:34 
hey Vielen Dank für deine Unterstützung!!!!!

Dieses FORUM ist das BESTE :lol: :lol: :lol: :lol: :lol: