其他分享
首页 > 其他分享> > SysUtils.StrLComp、SysUtils.StrLIComp

SysUtils.StrLComp、SysUtils.StrLIComp

作者:互联网

SysUtils.StrLComp、SysUtils.StrLIComp

StrLComp、StrLIComp 与 StrComp、StrIComp 基本是一样的, 只是多了一个参数用来指定有效长度.
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
const
  s1 = 'abc123';
  s2 = 'ABC456';
var
  i: Integer;
begin
  i := StrLComp(PChar(s1), PChar(s2), 6);
  ShowMessage(IntToStr(i)); {32}

  i := StrLIComp(PChar(s1), PChar(s2), 6);
  ShowMessage(IntToStr(i)); {-3}

  i := StrLComp(PChar(s1), PChar(s2), 3);
  ShowMessage(IntToStr(i)); {32}

  i := StrLIComp(PChar(s1), PChar(s2), 3);
  ShowMessage(IntToStr(i)); {0}
end;

end.
SysUtils 单元下的公用函数目录

posted on 2008-05-12 16:52  万一  阅读(2264)  评论(0)  编辑  收藏

标签:PChar,s2,s1,SysUtils,StrLComp,StrLIComp
来源: https://blog.51cto.com/u_14617575/2746268