![]() |
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; |
Re: Maximum wir überschritten!
Wo genau tritt denn der fehler auf?
Delphi-Quellcode:
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?
if calculate_dg.Cells[calculate_dg.FixedCols,Pred(calculate_dg.RowCount)] <> '' then
calculate_dg.RowCount := Succ(calculate_dg.RowCount); Solltest vielleicht deine If abfrage etwas abaendern. |
Re: Maximum wir überschritten!
Eine Zeile drunter.
Delphi-Quellcode:
calculate_dg.Cells[calculate_dg.FixedCols,Pred(calculate_dg.RowCount)] := form4.StringGrid.Cells[0,Index];
|
Re: Maximum wir überschritten!
Hinter dem vorletzten oder dem letzten if ... then fehlt ein begin.
jkr |
Re: Maximum wir überschritten!
Fehlen da nicht Begin und End im if?
Das ist sonst alles ziemlich komisch eingerückt. |
Re: Maximum wir überschritten!
Ich denke nicht, dass das hier eine Rolle in meinem Code spielt. Mann kann es auch so prgrammieren, oder? :-D
|
Re: Maximum wir überschritten!
Zitat:
|
Re: Maximum wir überschritten!
:-D , okay aber dann passiert gar nichts.
Liegt das hier dran?
Delphi-Quellcode:
...if Index > -1 then...
|
Re: Maximum wir überschritten!
Zitat:
|
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 02:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz