免费帕斯卡读取 TEdit 输入



我正在尝试找到一种方法来读取TEdit输入,然后计算输入的单词在段落中使用了多少次。基本上,此应用程序的工作方式是您将一段文本添加到第一个文本框中,然后在第二个文本框中输入要选择的单词,然后在第三个文本框中键入新单词,最后原始文本将添加到最后一个文本框中替换的单词。我需要计算最终文本框下方替换了多少个单词。真的很感激一些建议!

unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
edit4.Text:=Stringreplace(Edit1.Text, Edit2.Text, Edit3.Text,
[rfReplaceAll, rfIgnoreCase]);
edit3.Text:=
Label5.Caption:=(c);
end;
end.

您可以像这样获取要替换的单词数,然后在用户界面中将其考虑在内应该非常简单。

最新更新