[Gambas-user] type mismatch: wanted integer, got string instead

MSulchan Darmawan bleketux at ...626...
Tue Aug 25 06:35:42 CEST 2009


Dear sir,

I have the following code :

  DIM sRain AS String
  DIM iRain AS Integer
  DIM iPos AS Integer
  DIM iYear AS String
  DIM iMonth AS String

  modMain.Connect
  hRes = modMain.$Con.Exec("SELECT * FROM table")

  FOR EACH hRes

    iPos = hRes!id
    iYear = hRes!yr
    iMonth = hRes!mn
    sRain = hRes!r1
    
    ' PRINT iPos, iYear, iMonth, sRain
    iRain = CInt(sRain)
    IF iRain > 100 THEN PRINT iPos, iYear, iMonth

  NEXT

on this line : iRain = CInt(sRain)
I got the type mismatch error.
This is my first try to program on gambas.
So why the error happened ? Any suggestion to fix are welcome.

FYI, the database connected successfully, hRes!r1 is a string, sRain is
a string, and I'd like to get the integer value of sRain.
The possible value of sRain is : "0", "1", "2", "x", "-", NULL.

Help !
I'm using gambas2 2.8.2 on linux mint 7.

Thanks in advance.
Regards,
Sulchan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20090825/71dc532c/attachment.sig>


More information about the User mailing list