首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi中如何实现ascii码转换成十六进制的程序呀

2012-03-12 
delphi中怎么实现ascii码转换成十六进制的程序呀?实现ascii码转换成十六进制。。。。。。很急在线等待高手[解决

delphi中怎么实现ascii码转换成十六进制的程序呀?
实现ascii码转换成十六进制。。。。。。很急在线等待高手

[解决办法]
P : PChar;
Sour : AnsiString;
S : String;
begin
Sour := ......
P := Pointer(Sour);
S := '';
for i:=0 to Length(S)-1 do begin
S := S + ' ' + IntToHex(PByte(P)^ , 2);
P := P + 1;
end;
end;

[解决办法]
unit Unit1;

interface

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

type
TForm1 = class(TForm)
btn1: TButton;
edt1: TEdit;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btn1Click(Sender: TObject);
var
ansiCh: AnsiChar;
bytTmp: Byte;
strHexValue: string;
begin
ansiCh := 'a';

bytTmp := ord(ansiCh);

strHexValue := IntToHex(bytTmp,2);

edt1.Text := strHexValue;
end;

end.

热点排行