出于某种原因,使用德尔福SEARCHTEXT问题
SearchText := 'Program Files';
ReplaceText := 'Program Files (x86)';
SearchAndReplace(SearchText, ReplaceText);
会什么都不做,它只是将不会更改文本,使用其他任何文本时工作正常。
这是某种“保留”字吗?或()是什么让它不起作用?
procedure Tfc_Great.SearchAndReplace
(InSearch, InReplace: string) ;
var X, ToEnd : integer;
oldCursor : TCursor;
begin
oldCursor := Screen.Cursor;
Screen.Cursor := crHourglass;
with RichEdit1 do
begin
X := 0;
ToEnd := length(Text) ;
X := FindText(inSearch, X, ToEnd, []) ;
while X <> -1 do
begin
SetFocus;
SelStart := X;
SelLength := length(inSearch) ;
SelText := InReplace;
X := FindText(inSearch,
X + length(InReplace),
ToEnd, []) ;
end;
end;
Screen.Cursor := oldCursor;
end;
您正在使用的德尔福的版本? – 2009-09-28 12:00:37
更广泛的背景是什么?我从来没有听说过SearchAndReplace函数,我找不到任何helpfile条目。这是组件的一部分吗?我通常使用StringReplace进行搜索和替换操作。 – 2009-09-28 12:10:10
我不明白。你打算修改哪个字符串? – 2009-09-28 12:10:35