[Gambas-user] Bad string conversion etc.
Doriano Blengino
doriano.blengino at ...1909...
Wed Oct 1 12:11:53 CEST 2008
Rolf-Werner Eilert ha scritto:
> Still trying to convert a Gambas1 app to Gambas2. Basically, it begins
> to run. However, there are strange error message at some points, and I
> do not understand what causes them.
>
> IF CInt(wert[0]) > Maske.Count THEN Maske.Count = CInt(wert[0])
> Maske.Index = CInt(wert[0] - 1)
>
> Gambas will stop at the second line complaining "Type mismatch: wanted
> Number got String instead".
>
> Well, wert[0] at this time contains the string "1". This is a string
> with a number, and CInt should convert it to a numeric value, shouldn't
> it? (I tested to leave out the "- 1", this resulted in "Bad index" for
> the tabstrip!)
>
I would write:
Maske.Index = CInt(wert[0]) - 1
but it is said that "gambas has automatic type conversion": I can't
understand it fully, because it seems to me that your example should
work, and also could (should?) work the following:
Maske.Index = wert[0] - 1
To let this last line work, gambas should understand that the whole
expression to the right of the "=" should be an integer, and convert the
wert[0] string to an integer; and this is the same case as your first
temptative.
Regards,
Doriano Blengino
More information about the User
mailing list