首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

判断ListBox中选中的项中是否包含‘.’和‘_’?解决办法

2012-03-04 
判断ListBox中选中的项中是否包含‘.’和‘_’?判断ListBox中选中的项中是否包含‘.’和‘_’?如果有发出提示.[解

判断ListBox中选中的项中是否包含‘.’和‘_’?
判断ListBox中选中的项中是否包含‘.’和‘_’?如果有发出提示.

[解决办法]
procedure TForm1.ListBox1Click(Sender: TObject);
function ii(str:string):boolean;
begin
result:=false;
if (pos('.',str)>0) or (pos('_',str)>0) then
result:=true;
end;
begin
if ii(self.ListBox1.Items[listbox1.ItemIndex]) then
showmessage('存在.或者_');
end;
[解决办法]
procedure TForm1.ListBox1Click(Sender: TObject);
var
 i, j:integer;
str: string;
begin
 /// i:=listbox1.Items.Count ;
i:=ListBox1.Items.Count-1;
for i:=0 to i do
if ListBox1.Selected[i] then
begin
str:=ListBox1.Items.Strings[i];
if pos('.',str)=0 or pos('-',str)=0 then
showmessage('1');
end;
end;
end.

热点排行