些过程可以解决你的问题。 procedure SearchByPYIndexStr(Const SourceStrs:TStringList;Const PYIndexStr:string;Const IType:Integer; Box:TListBox); label NotFound; var i, j :integer; hzchar :string; begin box.Items.Clear; for i:=0 to SourceStrs.Count-1 do begin for j:=1 to Length(PYIndexStr) do begin if Length(SourceStrs[i])=0 then goto NotFound; hzchar:=SourceStrs[i][j]; if PYIndexStr[j] <> hzchar then goto NotFound; end; if (IType=0)or((IType=1)and(codes[integer(sourcestrs.Objects[i])][1]='*'))or((IType=2)and(codes[integer(sourcestrs.Objects[i])][1]='^')) then box.Items.Addobject(SourceStrs[i],sourcestrs.Objects[i]); NotFound: end; end;
StringList.Text := StringReplace(StringList.Text, '1', '',[rfReplaceAll]);
StringList.Text := StringReplace(StringList.Text, '0', '',[rfReplaceAll]);
StringList.Text := StringReplace(StringList.Text, '2', '',[rfReplaceAll]);
..................你可以使用循环来实现!!!取你要替换的ASCII码!!
在下拉框、列表框、memo等凡是含有大量供选择数据的控件中,实现根据用户所按字符或数字,重新提供供选的内容(输入字符包括数字、英文字母、拼音首字母),连续直至唯一选择。例如人事管理,叫王某,输入w,memo中显示所有姓王的;叫Linda的,输入l,memo中显示所有有L的;总之,就像Delphi帮助中查函数一样索引定位记录。
kaidu(Roger):谢谢,我没留心,现在好了!
procedure SearchByPYIndexStr(Const SourceStrs:TStringList;Const PYIndexStr:string;Const IType:Integer; Box:TListBox);
label NotFound;
var
i, j :integer;
hzchar :string;
begin
box.Items.Clear;
for i:=0 to SourceStrs.Count-1 do
begin
for j:=1 to Length(PYIndexStr) do
begin
if Length(SourceStrs[i])=0 then goto NotFound;
hzchar:=SourceStrs[i][j];
if PYIndexStr[j] <> hzchar
then goto NotFound;
end;
if (IType=0)or((IType=1)and(codes[integer(sourcestrs.Objects[i])][1]='*'))or((IType=2)and(codes[integer(sourcestrs.Objects[i])][1]='^')) then
box.Items.Addobject(SourceStrs[i],sourcestrs.Objects[i]);
NotFound:
end;
end;