Delphi-PRAXiS
Seite 1 von 2  1 2   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Maximum wir überschritten! (https://www.delphipraxis.net/122676-maximum-wir-ueberschritten.html)

thiagojonas 20. Okt 2008 14:20


Maximum wir überschritten!
 
Hallo jungs.
Ich kriege hierbei immer eine Fehlermeldung. Das Maximum des Listenindex (-1) wir überschritten.
Was ist hier falsch?

Delphi-Quellcode:
procedure TForm1.start_btnClick(Sender: TObject);
var datum:string;
var Txt2Find : String;
    Index   : Integer;

 function GetGrid2Index(Grid:TStringGrid;Txt2Find:String):Integer;
 var i : Integer;
 begin
  Result:=-1;
  with Grid do
   for i:=FixedRows to RowCount -1 do
    if (form4.StringGrid.Cells[1,i] = Txt2Find) then begin // < we compare col 1
     Result:=i;
     Break;
     end;
   end;

begin
      datum := DateToStr(Now);
      Txt2Find:=ComboBox.text;
      Index  :=GetGrid2Index(form4.StringGrid,Txt2Find);
   if Index>-1 then
   if calculate_dg.Cells[calculate_dg.FixedCols,Pred(calculate_dg.RowCount)] <> '' then
      calculate_dg.RowCount := Succ(calculate_dg.RowCount);
      calculate_dg.Cells[calculate_dg.FixedCols,Pred(calculate_dg.RowCount)] := form4.StringGrid.Cells[0,Index];
      calculate_dg.Cells[1,Pred(calculate_dg.RowCount)] := ComboBox.text;
      calculate_dg.Cells[2,Pred(calculate_dg.RowCount)] := form4.StringGrid.Cells[8,Index];
      calculate_dg.Cells[3,Pred(calculate_dg.RowCount)] := protokoll_cb.Text;
      calculate_dg.Cells[4,Pred(calculate_dg.RowCount)] := '';
      calculate_dg.Cells[5,Pred(calculate_dg.RowCount)] := datum;
      calculate_dg.Cells[6,Pred(calculate_dg.RowCount)] := FormatDateTime('hh:mm',now);
      SaveStringGrid(calculate_dg, 'Data/Penein/'+Txt2Find+'/'+Txt2Find+'.ini');
    end;
  end;

Volle 20. Okt 2008 14:31

Re: Maximum wir überschritten!
 
Wo genau tritt denn der fehler auf?

Delphi-Quellcode:
  if calculate_dg.Cells[calculate_dg.FixedCols,Pred(calculate_dg.RowCount)] <> '' then
      calculate_dg.RowCount := Succ(calculate_dg.RowCount);
kann es sein dass es hier kracht? Du kannst die Anzahl der Cells doch nich erst setzen nachdem du schaust was in einer Cell drinsteht oder?

Solltest vielleicht deine If abfrage etwas abaendern.

thiagojonas 20. Okt 2008 14:41

Re: Maximum wir überschritten!
 
Eine Zeile drunter.

Delphi-Quellcode:
 calculate_dg.Cells[calculate_dg.FixedCols,Pred(calculate_dg.RowCount)] := form4.StringGrid.Cells[0,Index];

jottkaerr 20. Okt 2008 14:45

Re: Maximum wir überschritten!
 
Hinter dem vorletzten oder dem letzten if ... then fehlt ein begin.

jkr

Frankfurtoder 20. Okt 2008 14:48

Re: Maximum wir überschritten!
 
Fehlen da nicht Begin und End im if?

Das ist sonst alles ziemlich komisch eingerückt.

thiagojonas 20. Okt 2008 15:02

Re: Maximum wir überschritten!
 
Ich denke nicht, dass das hier eine Rolle in meinem Code spielt. Mann kann es auch so prgrammieren, oder? :-D

DeddyH 20. Okt 2008 15:03

Re: Maximum wir überschritten!
 
Zitat:

Mann kann es auch so prgrammieren, oder?
Sicherlich, dann bekommt man halt die Fehler, die Du beschreibst :stupid:.

thiagojonas 20. Okt 2008 15:06

Re: Maximum wir überschritten!
 
:-D , okay aber dann passiert gar nichts.

Liegt das hier dran?

Delphi-Quellcode:
...if Index > -1 then...

DeddyH 20. Okt 2008 15:08

Re: Maximum wir überschritten!
 
Zitat:

Delphi-Quellcode:
if Index>-1 then
   if calculate_dg.Cells[calculate_dg.FixedCols,Pred(calculate_dg.RowCount)] <> '' then
      calculate_dg.RowCount := Succ(calculate_dg.RowCount);

Alles was danach kommt, ist weder von der ersten noch von der zweiten Prüfung betroffen.

thiagojonas 20. Okt 2008 15:10

Re: Maximum wir überschritten!
 
also so:

Delphi-Quellcode:
 if Index>-1 then
begin
   if calculate_dg.Cells[calculate_dg.FixedCols,Pred(calculate_dg.RowCount)] <> '' then
begin
      calculate_dg.RowCount := Succ(calculate_dg.RowCount);
      calculate_dg.Cells[calculate_dg.FixedCols,Pred(calculate_dg.RowCount)] := form4.StringGrid.Cells[0,Index];
      calculate_dg.Cells[1,Pred(calculate_dg.RowCount)] := ComboBox.text;
      calculate_dg.Cells[2,Pred(calculate_dg.RowCount)] := form4.StringGrid.Cells[8,Index];
      calculate_dg.Cells[3,Pred(calculate_dg.RowCount)] := protokoll_cb.Text;
      calculate_dg.Cells[4,Pred(calculate_dg.RowCount)] := '';
      calculate_dg.Cells[5,Pred(calculate_dg.RowCount)] := datum;
      calculate_dg.Cells[6,Pred(calculate_dg.RowCount)] := FormatDateTime('hh:mm',now);
      SaveStringGrid(calculate_dg, 'Data/Penein/'+Txt2Find+'/'+Txt2Find+'.ini');
   end;
  end;
 end;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:52 Uhr.
Seite 1 von 2  1 2   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz