📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetNum(stra,str:string):integer;//eg. stra='A';str:='ABCABC';
var
i,j:integer;
begin
j:=0;
result:=0;
for i:=1 to length(str) do begin
if strcomp(pchar(stra), pchar(copy(str,i,1)) )=0 then
j:=j+1;
end;
result:=j;
end;
function StrCount(const Sub: string; Str: string): Integer;
var
nPos: Integer;
begin
Result := 0;
nPos := Pos(Sub, Str);
while nPos > 0 do
begin
Inc(Result);
Delete(Str, 1, nPos + Length(Sub) - 1);
nPos := Pos(Sub, Str);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text:= inttostr( StrCount(edit1.Text , memo1.Text) );
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -