2017-03-16 64 views
0

我試圖找到一種方法來讀取一個TEdit輸入,然後計算在段落中使用輸入的詞多少次。基本上,這個應用程序的工作方式是在第一個文本框中添加一段文本,然後在第二個文本框中鍵入要選擇的單詞,然後在第三個文本框中鍵入新單詞,最後原始文本將會是添加到最後一個文本框中的替換詞。我需要計算最終文本框下面有多少個單詞已被替換。真的很感謝一些建議!免費pascal閱讀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. 

回答

0

你可以得到的單詞數來代替like this,那麼它考慮到了用戶界面應該是相當簡單的。

+0

或(更換前 - 更換)div(replacewith-replaceto) –