[Gambas-user] Maybe a bug with val functiun
Olivier Coquet
olinux at ...289...
Sat Nov 8 18:00:14 CET 2003
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
More information about the User
mailing list