[Gambas-user] Maybe a bug with val functiun

Benoit Minisini gambas at ...2...
Sun Nov 9 18:37:56 CET 2003


Le Samedi 8 Novembre 2003 18:00, Olivier Coquet a écrit :
> i think i've detected a bug in the Val() function gambas V0.71 on RH9
>
> i'll try to be clare but........
>
> if you use the val() function on a variable called num
> like this:
>
> i=val(num)
>
> if num is = to "123" all is ok, but if num="ert" sometime this result in
> NULL for i, sometime this result in an error mismatch date, num or boolean
> expected.
>
> i've seen that in a fct writed for my convenience I give you the complete
> code to reproduct the error.
> Note than if the fct is executed correctly for the first time, second time
> never generate an error, and if the code is executed with error the first
> time, second time generate allway an error.......!!!!!
>
> start of code..........
>
> PUBLIC FUNCTION dte_conv(dte AS String, rev AS Boolean) AS String
> ' Fonction de convertion de date, si rev = true format = bdd
> ' si rev = false format à la française
>   DIM m AS String
>   DIM j AS String
>   DIM y AS String
>
>   m=""
>   j=""
>   y=""
>
>   IF rev = FALSE THEN
>
>     j = Left$(dte,2)
>     m = Mid$(dte,4,2)
>     y = Right$(dte,2)
>
>       IF (Val(j) > 31) OR (Val(m) > 12)THEN
>         RETURN ("")
>       ELSE
>         RETURN (m & "-" & j & "-" & y)
>       ENDIF
>
>
>   ELSE
>
>     m = Left$(dte,2)
>     j = Mid$(dte,4,2)
>     y = Right$(dte,2)
>
>
>       IF (Val(j) > 31) OR (Val(m) > 12)THEN
>         RETURN ("")
>       ELSE
>         RETURN (j & "-" & m & "-" & y)
>       ENDIF
>
>
>
>   ENDIF
> END
>
> ........end of code
>
> Regards
> Olivier
>

Hi, Olivier.

It's a pity that you don't give me more details to reproduce the bug. See my 
answer to Rob later too.

Another point: if you want to start a new thread on the mailing-list, DON'T 
reply to a previous post !

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...





More information about the User mailing list