AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

syntax ord(x)

Ein Thema von Mb123 · begonnen am 27. Feb 2007 · letzter Beitrag vom 27. Feb 2007
Antwort Antwort
Mb123

Registriert seit: 7. Jun 2006
33 Beiträge
 
#1

syntax ord(x)

  Alt 27. Feb 2007, 15:37
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:
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;
ich bekommen nun aber die meldung: ..Incompatible types..
kann mir da jemand weiterhelfen ? danke
  Mit Zitat antworten Zitat
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#2

Re: syntax ord(x)

  Alt 27. Feb 2007, 15:39
Hi,

ListBox1.Items.Add(IntToStr(ord(b[1]));

Ord() erwartet einen Char und keinen String

PS: Wobei ich davon ausgehe das du mit

b := Copy(text, 0, i); EIGENTLICH

b := Copy(text, i, 1); meinst.. sonst bekommst du nämlich keine Chars

Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#3

Re: syntax ord(x)

  Alt 27. Feb 2007, 15:40
Du kannst Ord nicht auf Strings, sondern nur auf einen Char anwenden
Markus Kinzler
  Mit Zitat antworten Zitat
Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.755 Beiträge
 
Delphi 10.4 Sydney
 
#4

Re: syntax ord(x)

  Alt 27. Feb 2007, 15:41
Hallo,

ist vielleicht besser so?

Delphi-Quellcode:
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;
Grüße
Klaus
Klaus
  Mit Zitat antworten Zitat
Robert Marquardt
(Gast)

n/a Beiträge
 
#5

Re: syntax ord(x)

  Alt 27. Feb 2007, 15:42
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;
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#6

Re: syntax ord(x)

  Alt 27. Feb 2007, 15:43
@Klaus01: Nein b muß vom Typ Char sein.
Markus Kinzler
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:59 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz