怎样把字符串转化为16进制? 见标题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 思路:用Ord取得每个字符的ASCII码,然后用IntToHex转化为16进制字符。代码自己写吧,应该不难 function IntToHex(Value: Integer; Digits: Integer): string; overload;function IntToHex(Value: Int64; Digits: Integer): string; overload;procedure TForm1.Button1Click(Sender: TObject);var i: Integer;begin Label1.Caption := ''; for i := 1 to Length(Edit1.Text) do begin try Label1.Caption := Label1.Caption + IntToHex(Edit1.Text[i],2) + ' '; except Beep; end; end;end; tmpint:integer;if ( ord(ch)>127 ) or (ord(ch)<32) thenbegin tmpint:=ord(ch) inttohex(tmpint);end; 还是看 windofsun(太阳风) 的吧。 将字符串转成整型,然后用InttoHex转成16进制的字符串。 这样看看行不行:var Form1: TForm1;function gethexd(str:pchar):pchar;stdcall;external'Project4.dll';function getlinebyte(str:pchar):pchar;stdcall;external'Project4.dll';function gettotalbyte(str:pchar):pchar;stdcall;external'Project4.dll';implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);var s:string;begin memo1.clear; s:=gethexd(pchar(edit1.text)); memo1.lines.Add(s); edit2.text:=string(getlinebyte(pchar(edit1.text))); edit3.text:=string(gettotalbyte(pchar(edit1.text)));end;procedure TForm1.FormDblClick(Sender: TObject);begin showmessage(inttostr(length(memo1.text)));end;end.动态连接库是这样的:library Project4;uses Unit1 in 'Unit1.pas' {Form1};{$R *.RES} exports gethexd,getlinebyte,gettotalbyte;beginend.就这样了。我刚才试了一下全部完全达到你的要求。 我想问有什么方法可以实DBGrid实现复选框列? 请教F1Book如何插入图片? 数据库建表 想让窗体上控件的大小随着窗体大小的改变而改变,该怎样做? 如何判断一个QuickRep的打印任务完成? 紧急求助!请各位高手帮忙! 如何把一个字节数组转换为流? xiao problem 请问如何在移动DBGrid的滚动条时而不移动记录指针?thanks! DELPHI有关MSCOMM的问题 delphi几是中文版? d6有没有好书啊?
function IntToHex(Value: Int64; Digits: Integer): string; overload;procedure TForm1.Button1Click(Sender: TObject);var
i: Integer;
begin
Label1.Caption := '';
for i := 1 to Length(Edit1.Text) do
begin
try
Label1.Caption := Label1.Caption + IntToHex(Edit1.Text[i],2) + ' ';
except
Beep;
end;
end;
end;
begin
tmpint:=ord(ch)
inttohex(tmpint);
end;
Form1: TForm1;
function gethexd(str:pchar):pchar;stdcall;external'Project4.dll';
function getlinebyte(str:pchar):pchar;stdcall;external'Project4.dll';
function gettotalbyte(str:pchar):pchar;stdcall;external'Project4.dll';implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
memo1.clear;
s:=gethexd(pchar(edit1.text));
memo1.lines.Add(s);
edit2.text:=string(getlinebyte(pchar(edit1.text)));
edit3.text:=string(gettotalbyte(pchar(edit1.text)));
end;procedure TForm1.FormDblClick(Sender: TObject);
begin
showmessage(inttostr(length(memo1.text)));
end;end.
动态连接库是这样的:library Project4;uses
Unit1 in 'Unit1.pas' {Form1};{$R *.RES}
exports
gethexd,getlinebyte,gettotalbyte;beginend.
就这样了。我刚才试了一下全部完全达到你的要求。