Autor Beitrag
Abu36
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: So 26.03.06 15:39 
hi,

ich habe 4 stringgrids, mit jeweils 3mal3 feldern, inhalt sind zahlen. sie liegen auf der form wie ein quadrat. also rechts neben stringgrid eins liegt stringgrid zwei, darunter drei und vier.
der inhalt soll überprüft werden, in dem die reihen, die spalten und das jeweilige stringgrid überprüft wird.
reihe eins wäre also stringgrid1.cells[i,0] + stringgrid2.cells[i,0] --> für i:= 0 bis 3.
spalten sind dem zu folge vertikal.
ich hab die reiehn, spalten und einzelnen stringgrid in einem arry of integer.
die summe aller zahlen in einer reihe, einer spalte oder eines stringgrids soll immer dieselbe sein.
bei überprüfen soll nun geschaut werden ob das stimmt und dann im edit-fenster ausgegeben werden.

jedoch kommt bei mir immer ein fehler: "kein gültiger integerwert" ???????????

Moderiert von user profile iconGausi: Ein paar ? aus dem Titel gelöscht.
Moderiert von user profile iconGausi: Topic aus Off Topic verschoben am So 26.03.2006 um 16:45
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 26.03.06 15:47 
Auch wenn in dem Sringgrid Zahlen drin stehen, sind es in erstmal "nur" Strings. Wenn man diese als ganze Zahlen behandeln will, muss man sie mit StrToInt in einen Integer umwandeln.

_________________
We are, we were and will not be.
Abu36 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: So 26.03.06 15:50 
ja, das hab ich ja gemacht
ausblenden Delphi-Quelltext
1:
reihe[1]:= strtoint(stringgri1.cells[i,0]) + strtoint(stringgri2.cells[i,0]);					

darf denn das plus da so stehen
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 26.03.06 15:53 
Stehen denn in den einzelnen Zellen wirklich Zahlen drin? Ein '', ' ', oder ein 'hallo' kann natürlich nicht vernünftig als Zahl interetiert werden.
Evtl. hilft StrToIntDef.

_________________
We are, we were and will not be.
Abu36 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: So 26.03.06 15:57 
ja, es stehen nur zahlen drin
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Mo 27.03.06 12:58 
Habs nicht probiert, aber:
müssen die StringGrid - Zellen nicht "Array of String" sein?
Reihe & Spalte als Integer-Array müsste ok sein.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 27.03.06 13:03 
probiere doch mal
ausblenden Delphi-Quelltext
1:
reihe[1]:= StrToIntDef(stringgri1.cells[i,0],0) + StrToIntDef(stringgri2.cells[i,0],0);					

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mo 27.03.06 13:09 
Ach so jetzt blick ichs! Du hast LEERE Felder im StringGrid oder? Das wär die erklärung! Entweder du schaust dir die Funktion StrToIntDef in der Delphi-Hilfe an (einfacher ;>) oder du prüfst einfach per if-Abfrage ob das Feld leer ist, bevor du damit rechnest. wenns leer ist, überspringen.
(sudoku-clon-alarm? ^^)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Abu36 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 27.03.06 15:12 
bin grad von der schule heim, werds jetzt mal probieren, die felder sind aber nicht leer. ist kein sudoku, aber sowas ähnliches
Abu36 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 27.03.06 15:23 
kroko, was bedeutet dieses --> ,0 bei
reihe[1]:= StrToIntDef(stringgri1.cells[i,0]<span style="color: red">,0</span>) + StrToIntDef(stringgri2.cells[i,0]<span style="color: red">,0</span>);´
????????
Abu36 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 27.03.06 15:25 
kroko, was bedeutet dieses --> ,0 bei
reihe[1]:= StrToIntDef(stringgri1.cells[i,0],0) + StrToIntDef(stringgri2.cells[i,0],0);
????????
Abu36 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 27.03.06 15:26 
kroko, was bedeutet dieses --> ,0 bei
ausblenden Delphi-Quelltext
1:
reihe[1]:= StrToIntDef(stringgri1.cells[i,0],0) + StrToIntDef(stringgri2.cells[i,0],0);					

???????? schuldigung für die zwei beiträge da
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 27.03.06 15:35 
aus der delphi hilfe ;)
Zitat:

Description

StrToIntDef converts the string S, which represents an integer-type number in either decimal or hexadecimal notation, into a number. If S does not represent a valid number, StrToIntDef returns Default.
Abu36 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 27.03.06 15:40 
wie muss dann das array sein: array of intdef?????
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mo 27.03.06 16:04 
Also.
1) Editbutton benutzen (aus 4 Beiträgen kann man echt auch einen machen...)
2) Delphi Hilfe benutzen bevor du fragst (Darum hab ich gesagt "Schau dir die funktion näher an"
3) Wenn die DH versagt, nimm die Forensuche.
4) Wenn auch die versagt versuchs mit Google.
5) Wenn du JETZT noch Hilfe brauchst, frag das Forum.

Deine Frage hätte sich durch diese 5 Punkte leicht geklärt...
und zwar ab meinem letzten Beitrag.
Hättest du dir zum Beispiel die DH von StrToIntDef angeguckt, dann hättest du gesehen, dass die Funktion den Rückgabetyp Integer hat, was bedeutet dass dein Array weiterhin Integer bleibt (IntDef gibt es nicht, oder nennst du deine Arrays "Int" nur weil die andere Funktion "StrToINT" heist...? ^^)

Weiterhin bitte ich dich, das alles nich falsch zu verstehen, niemand will dich beleidigen... viel Glück fürs nächste mal ^^ Ich hoff dein Problem konnte gelöst werden..

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.