![]() |
syntax ord(x)
hallo,
ich möchte den inhalt eines strings in Ascii-zahlen umwandeln und die zahlen dann in einer listbox schreiben. das ist nun mein code:
Delphi-Quellcode:
ich bekommen nun aber die meldung: ..Incompatible types..
procedure TForm1.Button1Click(Sender: TObject);
var s,b:string ; i:integer; begin s := edit1.text; for i:=1 to length(s) do b := Copy(text, 0, i); ListBox1.Items.Add(IntToStr(ord(b)) ; end; kann mir da jemand weiterhelfen ? danke |
Re: syntax ord(x)
Hi,
Delphi-Quellcode:
;)
ListBox1.Items.Add(IntToStr(ord(b[1]));
Ord() erwartet einen Char und keinen String ;) PS: Wobei ich davon ausgehe das du mit
Delphi-Quellcode:
EIGENTLICH
b := Copy(text, 0, i);
Delphi-Quellcode:
meinst.. sonst bekommst du nämlich keine Chars ;)
b := Copy(text, i, 1);
Gruß Neutral General |
Re: syntax ord(x)
Du kannst Ord nicht auf Strings, sondern nur auf einen Char anwenden
|
Re: syntax ord(x)
Hallo,
ist vielleicht besser so?
Delphi-Quellcode:
Grüße
procedure TForm1.Button1Click(Sender: TObject);
var s,b:string ; i:integer; begin s := edit1.text; for i:=1 to length(s) do begin b := s[i]; ListBox1.Items.Add(IntToStr(ord(b)) ; end; end; Klaus |
Re: syntax ord(x)
Ord() wirkt auf ordinale Datentypen, aber b ist ein string.
Alles weg was nicht noetig ist.
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var I: Integer; begin for I := 1 to Length(Edit1.Text) do ListBox1.Items.Add(IntToStr(Ord(Edit1.Text[I])); end; |
Re: syntax ord(x)
@Klaus01: Nein b muß vom Typ Char sein.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:55 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