[Gambas-user] Type mismatch.

Benoit Minisini gambas at ...1...
Tue Jul 20 19:30:08 CEST 2004


On Tuesday 20 July 2004 01:13, Leo Barnhoorn wrote:
> Hello Benoit,
>
> I have a Type mismatch: wanted Byte, got String instead.
>
> CByte
> 	Byte = CByte ( Expression )
>
> Converts an expression into a byte. Expression is first converted into an
> integer. Then, if this integer overflows the byte range, it is truncated.
>
> Example PRINT CByte("17") = 17
>
> So if i'am not wrong this has to work also, following the explanation
> above:
>
> 		CByte("&H" & Mid(sHex, i * 2 + 1, 2))
>
> But this sets the error : Type mismatch: wanted Byte, got String instead
>
> For CInt / CInteger the same.
>
> Thanks for really nice Gamber version 0.95.
>
> Regards,
> Leo.
>
>

This is not a bug. You must use the Val() function to convert a string like 
"&H7" to a number. CByte() is just a datatype converter. It does not work 
like in VB - It is more logical :-)

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list