![]() |
Stringgrid & Arrays
Hi Leute,
ich hab grad wieder mal eine Blockade...ich bekomms einfach nicht hin... :coder2: Ich habe 100 Zufallszahlen in Array reinsortieren lassen. Nun müssen diese 100 sortierten Zahlen in ein Stringgrid rein und zwar wie folgt... In die 1. Spalte des Grids müssen die Array 1-10, in die 2. Spalte die Arrays 11-20 usw...(Es gibt 10 Spalten). => logischerweise jedes Array in ne eigene Zeile - absteigend mit Array nr. Ich bekomm einfach keine Schleife dafür hin...Kann mir jemand helfen? Nur als Info das Stringgrid beginnt an der Stelle [0,0] |
Re: Stringgrid & Arrays
So sieht der Code übrigens aus wenn ich keine Schleife für a (mein Problem) mit reinsetze:
Delphi-Quellcode:
a := 0;
c := 0; for b := 0 to 9 do begin c := c + 1; stringgrid2.Cells[a,b] := inttostr (word1[c]); end; for b := 0 to 9 do begin a := 1; c := c + 1; stringgrid2.Cells[a,b] := inttostr (word1[c]); end; for b := 0 to 9 do begin a := 2; c := c + 1; stringgrid2.Cells[a,b] := inttostr (word1[c]); end; //usw. a immer weiter bis 9... |
Re: Stringgrid & Arrays
Schau dir mal "DIV" und "MOD" an!
|
Re: Stringgrid & Arrays
ich kenne div (teilen) & mod (rest) zur genüge...bekomm es damit aber nicht hin.
sonst hätte ich es damit ja schon gemacht :gruebel: |
Re: Stringgrid & Arrays
Zitat:
Möchtest du einfach die Zahlen 1-10 in Spalte 1, 11-20 in Spalte 2 etc, oder wie? :gruebel: |
Re: Stringgrid & Arrays
Delphi-Quellcode:
c := 0;
for acol:=0 to 9 do begin for arow:= 0 to 9 do begin stringgrid2.Cells[acol,arow] := inttostr(word1[c]); inc(c); end; end; |
Re: Stringgrid & Arrays
Delphi-Quellcode:
Wenn das Array von 0 bis 99 laufen würde, müsste man jeweils die "-1" weglassen :!:
var
i: integer; begin for i := 1 to 100 StringGrid2.Cells[(i-1) div 10, (i-1) mod 10] := Word1[i]; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:52 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 by Thomas Breitkreuz