[Gambas-user] type mismatch: wanted integer, got string instead (solved)
Fabien Bodard
gambas.fr at ...626...
Fri Aug 28 10:50:38 CEST 2009
2009/8/26 MSulchan Darmawan <bleketux at ...626...>:
> Pada Tue, 25 Aug 2009 04:29:32 -0600
> Dimitris Anogiatis <dosida at ...626...> menulis:
>
>> give it a try MSulchan and tell me if it works for you
>
> Thank you Dimitris, after a little try and error, I change the code
> into like this :
>
> IF IsNull(Val(sRain)) = FALSE THEN
> IF InStr(LCase(sRain), "x") > 0 OR InStr(sRain, "-") > 0 OR InStr(sRain, ".") > 0 THEN
> IF InStr(LCase(sRain), "x") > 0 THEN fRain = 0
> IF InStr(sRain, "-") > 0 THEN fRain = 0
> IF InStr(sRain, ".") > 0 THEN
> sRainy = Replace(sRain, ".", ",")
> fRain = Val(sRainy)
> ENDIF
> ELSE
> fRain = CFloat(Val(sRain))
> ENDIF
> ELSE
> fRain = -1
> ENDIF
>
IF IsNull(Val(sRain)) = FALSE THEN
IF InStr(LCase(sRain), "x") > 0 OR InStr(sRain, "-") > 0 THEN
fRain=0
ELSE
try fRain = CFloat(sRain)
If ERROR THEN fRain=-1 'Not a Valid Number
ENDIF
ELSE
fRain=-1
ENDIF
It will Work
> Decided to change iRain (integer) to fRain (float).
> As Fabien told that Val() use current localization, so I need to change
> the decimal separator from dot to comma.
> And I think it is fast enough :D
>
> Thanks again.
>
> --
> Cheers,
> [-Sulchan-]
> Terbang dengan claws-mail 3.7.2
> Mendarat di hardy heron 8.04.3 LTS
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
More information about the User
mailing list