unit1.~pas

来自「RS232串口通讯随书源码」· ~PAS 代码 · 共 71 行

~PAS
71
字号
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    txtInput: TEdit;
    cmdCalc: TButton;
    cmdClose: TButton;
    mANSI: TMemo;
    mWide: TMemo;
    procedure cmdCalcClick(Sender: TObject);
    procedure cmdCloseClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

//以下程序将字符串中的字符的编码一一找出
procedure TForm1.cmdCalcClick(Sender: TObject);
var
  InputStr:String;
  InputStrW:WideString;
  i,StrLen:Integer;
  tmpStr:String;
begin
   //以下进行长字符串
   InputStr:=txtInput.Text;
   InputStrW:=txtInput.Text;
   StrLen:=Length(InputStr);
   tmpStr:='';
   //将每个字符的编码组成一个字符串
   for i:=1 to StrLen do
     tmpStr:=tmpStr + IntToStr(ord(InputStr[i])) + ' ';
   //将结果显示出来
   mANSI.Text:=tmpStr;
   //以下进行宽字符串
   StrLen:=Length(InputStrW);
   tmpStr:='';
   //将每个字符的编码组成一个字符串
   for i:=1 to StrLen do
     tmpStr:=tmpStr + IntToStr(ord(InputStrW[i])) + ' ';
   //将结果显示出来
   mWide.Text:=tmpStr;

end;

//结束程序
procedure TForm1.cmdCloseClick(Sender: TObject);
begin
  Close;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?