GARANTIR DESCONTO

Fórum Converter String To ASCII #330004

24/09/2006

0

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

Responder

Posts

24/09/2006

Will

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


Responder

Gostei + 0

25/09/2006

Macario

Ola.

Creio que seja assim



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



Responder

Gostei + 0

26/09/2006

Krischen

Valeu pessoal,

Agora rodou corretamente.

Obrigado a todos!!!


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar