Converter String To ASCII

Delphi

24/09/2006

Olá, estou tentando converter STRING´s em seu caracter ASCII correspondente através da Unit abaixo, porém estou recebendo o seguinte erro:

[Pascal Error] Unit1.pas(41): E2008 Incompatible types

Encontrei alguns tópicos sobre o assunto porém não consegui adaptar para minha unit.

Segue a Unit

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;

type
TForm1 = class(TForm)
edt1: TEdit;
edt2: TEdit;
btnConvertToASCII: TButton;
procedure btnConvertToASCIIClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function MyStrToAscii(Texto: string): string;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

Function TForm1.MyStrToAscii(Texto: string): string;
var
Tamanho,i : integer;
PalavraHex : String;
begin
Tamanho := Length(Texto);
for i := 1 to Tamanho do begin
PalavraHex:= PalavraHex + IntToStr(Ord(Texto))+ ´ ´; //Linha do Erro
end;
Result := PalavraHex;
end;

procedure TForm1.btnConvertToASCIIClick(Sender: TObject);
begin
edt2.Text := MyStrToAscii(edt1.Text);
end;

end.

Alguém pode me ajudar,
Desde já obrigado!!


Krischen

Krischen

Curtidas 0

Respostas

Will

Will

24/09/2006

Você deve converter caracter (tipo char) e não string.


GOSTEI 0
Macario

Macario

24/09/2006

Ola.

Creio que seja assim



PalavraHex:= PalavraHex + IntToStr(Ord(Texto[i]))+ ´ ´;



GOSTEI 0
Krischen

Krischen

24/09/2006

Valeu pessoal,

Agora rodou corretamente.

Obrigado a todos!!!


GOSTEI 0
POSTAR