[Gambas-user] How to check if it is a  valid date?

Jack jscops at ...11...
Sun Aug 22 08:45:46 CEST 2004


Le Vendredi 20 Août 2004 14:36, Hans-Martin Bundeshund a écrit :
> Salute Benoit,
>
> sorry to say, but I tested it with the yaer at last
> before your reply. I got the same results.
>
> Here is the source-snippet:
>
>
>     act_day = 20
>     act_month = 8
>     act_year = 2004
>
>     IF IsDate(Format$(act_day,"00") & "/" &
> Format$(act_month, "00") & "/" &
> Format$(act_year,"0000")) THEN
>       datum = Date(act_year,act_monat,act_day)
>     ELSE
>       message.Info("Date WRONG: " & act_day & "." &
> act_month & "." & act_year)
>     ENDIF
>
>
> Result: Date WRONG: 20.8.2004
>
>
> What I am doing wrong?
>
> regards,
>
> HM

To control my date i use the very usefull Cdate function.

see the example below and complete it according to your need.

PUBLIC FUNCTION Controle_date(Dte AS String) AS String
DIM Ndate AS Date
Ndate = CDate(Dte)
 RETURN Ndate
CATCH 
message.Error("Il y a une incohérence dans votre saisie \n Verifiez votre date 
SVP !")
END

~° Jack °~





More information about the User mailing list