Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Umwandlung TStrings in Integer (https://www.delphipraxis.net/92842-umwandlung-tstrings-integer.html)

Apollonius 27. Mai 2007 13:11

Re: Umwandlung TStrings in Integer
 
Ohne Code kann ich das absolut nicht kommentieren.

punker-lili 27. Mai 2007 13:12

Re: Umwandlung TStrings in Integer
 
auf seite eins steht der gesamte quelle code... und versuch 2 das mit dem integerarray...

Klaus01 27. Mai 2007 13:34

Re: Umwandlung TStrings in Integer
 
Dein zweiter Versuch sollte so vom Syntax her korrekt sein:

Delphi-Quellcode:
for j := 0 to F.Count - 1 do
  begin
    integerarray[j]:= StrToInt(F.Strings[j]);
 end;
Wie ist denn Dein IntegerArray definiert?

String in Zahlenwert umwandeln -> StrToInt (wandelt String in Integer um)
-> StrToFloat (wandelt String in ein Floatwert um)

So schwer ist das doch nicht.

Grüße
Klaus

Dunkel 27. Mai 2007 14:28

Re: Umwandlung TStrings in Integer
 
Ich vermute mal ganz stark, dass integerarray nicht deklariert wurde.

Delphi-Quellcode:
var
  integerarray: array of integer;
begin
  SetLength(integerarray, F.ItemsCount);
{..}
  for j := 0 to F.itemsCount - 1 do
    begin
      integerarray[j]:= StrToInt(F.Items[j]);
    end;
{..}
end;

Neutral General 27. Mai 2007 14:30

Re: Umwandlung TStrings in Integer
 
Hi

Ehm das Problem liegt ganz woanders.. du musst und darfst die Strings in deiner Liste gar nicht in Zahlen umwandeln!

So muss das heißen:
Delphi-Quellcode:
for j := 0 to F.itemsCount - 1 do
begin
  rows[j]:= SF.Items[j];
end;
Gruß
Neutral General

punker-lili 27. Mai 2007 16:12

Re: Umwandlung TStrings in Integer
 
@Neutral General: Was ist SF?

Items funktioniert nicht... ich habe die beiden Quelltexte (Neutral General,Dunkel) ausprobiert und jedesmal hat er ein Problem mit items... er sagt dazu "Undeclared identifier:'items'". Kann es daran liegen,dass ich Delphi 7 Personal benutze?

Apollonius 27. Mai 2007 16:14

Re: Umwandlung TStrings in Integer
 
Denk doch mal mit!
In einer TList heißt das nun mal Items. Bei TStrings muss es Strings heißen.

DeddyH 27. Mai 2007 16:24

Re: Umwandlung TStrings in Integer
 
Also, bei mir geht das hier:
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
var F: TStringList;
    integerarray: array of integer;
    i: integer;
begin
  F := TStringList.Create;
  try
    F.Add('1');
    F.Add('2');
    F.Add('3');
    F.Add('4');
    F.Add('5');
    F.Add('6');
    F.Add('7');
    F.Add('8');
    F.Add('9');
    F.Add('10');
    SetLength(integerarray,F.Count);
    for i := 0 to F.Count - 1 do
      integerarray[i] := StrToInt(F[i]);
    for i := 0 to Length(integerarray) - 1 do
      ShowMessage(Format('%d hat den Wert %d',[i,integerarray[i]]));
  finally
    FreeAndNil(F);
  end;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:54 Uhr.
Seite 3 von 3     123   

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