判断非逗号字符总数和逗号总数是否相等,相等就正确—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————

解决方案 »

  1.   

    象这样吧
    procedure TForm1.Button1Click(Sender: TObject);
      function Valid(Str:String):Boolean;
      begin
        if Str='' then
        begin
          Result:=True;
          exit;
        end;
        if (Str[Length(Str)]<>',')or(Trim(Str)='') then
        begin
          Result:=False;
          exit;
        end;
        Result:=True;
        while Pos(',',Str)>0 do
        begin
          if Pos(',',Str)>1 then
            Delete(Str,1,Pos(',',Str))
          else
          begin //如果','是第一个位置,那么格式不对
            Result:=False;
            exit;
          end;
        end;
      end;
    begin
      if not Valid(Edit1.Text) then
        ShowMessage('Error!')
      else
        ShowMessage('OK!');
    end;
      

  2.   

    不是很明白你的格式是什么?