Hola!

At 10:16 22/12/00 , you wrote: 
>
> Hi All
> I have a program that receives a partial date in a DBEdit control, but
when i
> try to validate de entry, i get a error message. What am i doing wrong ?
>  
> procedure TForm1.DBEdit1Exit(Sender: TObject);
>   var
>     DD,MM,S : String;
>   begin
>     S := DBEdit1.Text;
>     DD := S[1] + S[2};
>     MM := S[3] + S[4];
>     if (DD < '1') or (DD > '31') or (MM < '1') or (MM > '12') then


I assume that the edit text has leading zeroes for single-digit days and
months?
eg 01, 09
In that case you'll need to change the line above to 
  if (DD < '01') or (DD > '31') or (MM < '01') or (MM > '12') then

String comparisons work on a character by character comparison. It doesn't
recognise a string of digits as a number; so the leading zero in the string is
significant - '01' is different to '1'.

HTH, Paul.



__________________________________________________________
Paul Spain      mailto:[EMAIL PROTECTED]
__________________________________________________________

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"

Reply via email to