unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject); var i: Integer; str: string; begin memo1.Lines.Clear; str := ''; for i := 1 to 255 do begin str := str + format(' %.2x : %s ',[i,chr(i)]); if (i mod 8) = 0 then begin memo1.Lines.Append(str); str := ''; end; end; end;end.
用的什么版本的delphi,先转了asii字符吗?
// 创建一个空白窗体,然后添加一个 Memo(Memo1) 和一个 Button(Button1) ,双击 Button1,用下面的代码即可。function GetAscii(FromNum, ToNum: Integer): string; var I: Integer; begin for I := FromNum to ToNum do begin Result := Result + IntToStr(I) + #9 + Chr(I) + #13#10; end; end;procedure TForm1.Button1Click(Sender: TObject); begin Memo1.Clear; Memo1.Lines.Text := GetAscii(32, 126); end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
str: string;
begin
memo1.Lines.Clear;
str := '';
for i := 1 to 255 do
begin
str := str + format(' %.2x : %s ',[i,chr(i)]);
if (i mod 8) = 0 then
begin
memo1.Lines.Append(str);
str := '';
end;
end;
end;end.
// 创建一个空白窗体,然后添加一个 Memo(Memo1) 和一个 Button(Button1) ,双击 Button1,用下面的代码即可。function GetAscii(FromNum, ToNum: Integer): string;
var
I: Integer;
begin
for I := FromNum to ToNum do begin
Result := Result + IntToStr(I) + #9 + Chr(I) + #13#10;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Clear;
Memo1.Lines.Text := GetAscii(32, 126);
end;