⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 RS232串口通讯随书源码
💻 PAS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -