[Gambas-user] type mismatch: wanted integer, got string instead
Fabien Bodard
gambas.fr at ...626...
Tue Aug 25 08:23:13 CEST 2009
2009/8/25 MSulchan Darmawan <bleketux at ...626...>:
> Pada Mon, 24 Aug 2009 23:00:07 -0600
> Dimitris Anogiatis <dosida at ...626...> menulis:
>
>> this way iRain would always have an integer and you wouldn't have to
>> worry about
>> the mismatch error... assuming "0", "1", "2", "x", "-" and NULL are
>> the only values
>> used in your database.
>
> Thanks Dimitris and JY,
>
> Unfortunately, the possible values are more then that, it's just a
> sample.
> The values are amount of rainfall data, so it has numbers (0 to 400)
> also with floating number 0.5, 1.7, and so on.
> The field of old data on the database was set with string type, which
> "x" represent as a value less then 0.5, "-" represent as no rain, and
> NULL represent as no data.
>
> So, for temporary solution, I'll use TRY statement to exclude "x", "-",
> and NULL, but the problem is with the floating number.
> I don't know how to handle this yet.
> any idea how to solve this ?
you test the string first :
if instr(hResult!Fall, "-") >0 or if instr(hResult!Fall, "x") >0 or if
hResult!Fall=null then
iValue =0
else
if instr(hResult!Fall, "x") >0 then
iValue =0
else
iValue= CInt(val(hResult!Fall))
endif
Endif
Be carefull, the current localisation is used by Val()
on problem ... try iValue = CFloat(hResult!Fall) or iValue =
Cint(CFloat(hResult!Fall) )
http://www.gambasdoc.org/help/cat/conv?v3
>
> thanks in advance,
> Regards,
> Sulchan
>
> ------------------------------------------------------------------------------
> 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