你这些问题都是同样的道理,循环搜索procedure TForm1.Button3Click(Sender: TObject); var i,j,m:Integer; s,s1:string; str:TStrings; begin i:=self.RichEdit1.Lines.Count; if i=0 then Exit; str:=TStringList.Create; str.Clear; self.RichEdit2.Lines.Clear; for j:=0 to i-1 do begin s:=self.RichEdit1.Lines.Strings[j]; str.Clear; ExtractStrings([' '],[],PChar(s),str); m:=str.Count; if m<2 then Continue; s:=str.Strings[0]; s1:=str.Strings[1]; if (s='1') or (s='3') or (s='4') then self.RichEdit2.Lines.Add(s1); end; end;
var
i,j,m:Integer;
s,s1:string;
str:TStrings;
begin i:=self.RichEdit1.Lines.Count;
if i=0 then
Exit;
str:=TStringList.Create;
str.Clear;
self.RichEdit2.Lines.Clear;
for j:=0 to i-1 do
begin
s:=self.RichEdit1.Lines.Strings[j];
str.Clear;
ExtractStrings([' '],[],PChar(s),str);
m:=str.Count;
if m<2 then
Continue;
s:=str.Strings[0];
s1:=str.Strings[1];
if (s='1') or (s='3') or (s='4') then
self.RichEdit2.Lines.Add(s1);
end;
end;
2 用一个 TstringList 变量 转载 richedit 中内容
然后 用 Name 和Value 的关系 直接对应出来