Como transformar de String em inteiro ?

Delphi

02/07/2004

Bom dia a todos.

Estou precisando converter string em seu valor decimal de acordo com a tabela ASCII. O usuário informa uma string qualquer, eu leio a string e converto cada caractere em seu valor decimal.
EX:
T E S T E --> String
84 69 83 84 69 --> Valor decimal

Grato pela atenção.


Turbo Drive

Turbo Drive

Curtidas 0

Respostas

Vinicius2k

Vinicius2k

02/07/2004

Colega,

Veja:
function converte(S: String): String;
var i: integer;
begin
  Result:= ´´;
  for i:= 1 to Length(S) do
    Result:= Result + IntToStr(Ord(S[i]))
end;


Para usar :
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(converte(´TESTE´));
end;


Espero ter ajudado...

T+


GOSTEI 0
POSTAR