Autor Beitrag
Jagg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 635



BeitragVerfasst: Di 03.12.02 14:33 
Hallo !

Ich habe viele Dynamische EditFelder,die ich auslesen will !
Wenn in dem Feld was drin steht,soll er diese Zahl in eine Tabelle reinschreiben !
Überprüfe ich das so :
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
if TE[i].Text<>'0' then
    begin
      T.Append;
      T.FieldByName('Wieviel').AsString := TE[i].Text;
      T.Post;
    end;


....es geht aber nicht !

Jagg !
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Di 03.12.02 14:49 
Hi
Damit prüfst du ja nicht, ob in dem Feld überhaupt was steht, sondern ob was anderes als '0' drinsteht. Und was passiert wenn der User 'abc' reinschreibt? :? Ausserdem schreibst du leider nicht, was da nicht funktioniert. Mal ein Verbesserungsvorschlag:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
if TE[i].Text<>'' then 
  try
    x := StrToInt(TE[i].Text]);  //Oder StrToFloat usw.
    try
      T.Append; 
      T.FieldByName('Wieviel').AsInteger := x; 
      T.Post;
    except
      Cancel; 
    end;
  except
    on EconvertError do
      //Fehlermeldung oder Sonstwas
  end;


Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
Jagg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 635



BeitragVerfasst: Di 03.12.02 14:59 
ich habe so :

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
if Key = VK_F3 then
  begin
    T.DatabaseName := 'C:\BiBA\Mail\';
    T.TableName := 'Bestell.dbf';
    T.Open;
    if TE[i].Text<>'' then
    begin
      T.Append;
      T.FieldByName('Wieviel').AsInteger := StrToInt(TE[i].Text);
      T.Post;
    end;
    Close;
  end;


....aber er sagt "kein gültiger Integerwert" !

Jagg !
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Di 03.12.02 15:03 
Hi
dann solltest du an der Stelle mal mit dem Debugger prüfen, was tatsächlich in dem Editfeld drinsteht. Ein Problem könnte sein, dass deine Variable i vielleicht gar nicht auf das richtige Feld verweist.

Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 03.12.02 15:03 
Hi!

Was soll denn da i bitte sein?

Cu,
Udontknow
Jagg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 635



BeitragVerfasst: Di 03.12.02 15:12 
ich habs,hab vergessen i zu setzen !

das ist der code :
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
if Key = VK_F3 then
  begin
    i := 1;
    T.DatabaseName := 'C:\BiBA\Mail\';
    T.TableName := 'Bestell.dbf';
    T.Open;
    while TE[i].Text<>'' do
    begin
      T.Append;
      T.FieldByName('Wieviel').AsInteger := StrToInt(TE[i].Text);
      T.Post;
      inc(i);
    end;
Jagg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 635



BeitragVerfasst: Di 03.12.02 15:30 
das ist besser.... :
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
if Key = VK_F3 then
  begin
    T.DatabaseName := 'C:\BiBA\Mail\';
    T.TableName := 'Bestell.dbf';
    T.Open;
    for i := 1 to 40 do
    begin
      if TE[i].Text<>'' then
      begin
        T.Append;
        T.FieldByName('Wieviel').AsInteger := StrToInt(TE[i].Text);
        T.Post;
      end;
    end;
    Close;
  end;
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Di 03.12.02 15:37 
Hi
das beseitigt allerdings immer noch nicht das Problem, wenn in einem Edit mal keine Zahlen drinstehen. Du solltest das auf alle Fälle abfangen, oder von vorneherein die Eingabe in die Felder einschränken.

Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...