Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi zahlen in zwei stringgids vergleichen (lotto) (https://www.delphipraxis.net/127009-zahlen-zwei-stringgids-vergleichen-lotto.html)

Molzer 6. Jan 2009 14:48


zahlen in zwei stringgids vergleichen (lotto)
 
Hallo!

habe zwei stringgrids wo je 6 zahlen(eingetippt und zufall) stehen, diese würde ich jetzt gerne vergleichen.
dazu habe ich mir überlegt ich suche von den getippten in den zufalls zahlen,und gebe sie im einem tedit aus.

bin gerade beim suchen lernen und tue mir schwer..

Delphi-Quellcode:
begin
    x:=0;
    for i := 1 to 6 do
      begin if StringGrid1.Cells[1,0]=StringGrid2.Cells[i,0] then
      x:=x+1
      end;
      begin if StringGrid1.Cells[2,0]=StringGrid2.Cells[i,0] then
      x:=x+1
für die erste zelle würde das ja gehen aber bei der zweiten steh ich schon an..
wird sicher noch etwas einfacheres geben..

vielleicht kann mir jemand einen ansatz geben...

fg

Molzer 6. Jan 2009 14:49

Re: zahlen in zwei stringgids vergleichen (lotto)
 
Liste der Anhänge anzeigen (Anzahl: 1)
so siehts aus

DeddyH 6. Jan 2009 14:54

Re: zahlen in zwei stringgids vergleichen (lotto)
 
Du willst ermitteln, wieviele Richtige das sind? Müsste so funktionieren (aus dem Kopf getippt):
Delphi-Quellcode:
x := 0;
for i := StringGrid1.FixedCols to Pred(StringGrid1.ColCount) do
  if StringGrid2.Rows[0].IndexOf(StringGrid1.Cells[i,0]) > 0 then
    inc(x);

Molzer 6. Jan 2009 15:02

Re: zahlen in zwei stringgids vergleichen (lotto)
 
das ist für mich als anfänger noch etwas zu hoch.. leider..
bin gerade etwas mit true and false zu konstruieren :lol:
fg

DeddyH 6. Jan 2009 15:38

Re: zahlen in zwei stringgids vergleichen (lotto)
 
Das war sowieso nicht ganz richtig, müsste wohl eher so heißen:
Delphi-Quellcode:
x := 0;
for i := StringGrid1.FixedCols to Pred(StringGrid1.ColCount) do
  if StringGrid2.Rows[0].IndexOf(StringGrid1.Cells[i,0]) > Pred(StringGrid2.FixedCols) then
    inc(x);


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:22 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