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

解决方案 »

  1.   

    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;
      

  2.   

    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.