如题

解决方案 »

  1.   

    try
      strtodate('2004-12-15 8:30:25');
    except
      showmessage('不是合法时间');
    end;
      

  2.   

    不过,有时间好像不行,要用SQL的isdate()函数了吧?
      

  3.   

    function TryStrToDate(const S: string; out Value: TDateTime): Boolean; overload;試下這個
      

  4.   

    try
      strtodate('2004-12-15 8:30:25');
    except
      showmessage('不是合法时间');
    end;
      

  5.   

    我不要异常,有什么有其他办法?
    比如
    1千次,1万次,甚至100万次的try strtodate('sdjflkdjfkd') except ;end;,是不是不好,异常多了会不会导致内存错误呢?
    有没有其他验证办法?
    其实try strtodate 我早就想过了。
      

  6.   

    try
      strtodate('2004-12-15 8:30:25');Delphi自己都会异常,不行。
    像aiirii(ari-爱的眼睛) 说的TryStrToDate,Delphi自己不会异常,还算可行。
      

  7.   

    if trystrtodatetime(edit1.Text,D)  then
      exit
      else
       showmessage('您的输入不正确!如02-2-2是正确的!');
      

  8.   

    对,就用trystrtodatetime这个函数就可以了。多调试一下吧。