Reputation: 8816
In order to settle a bet with one of my colleagues, I would like to find out if VB6 natively supports any unsigned data types.
I believe the answer to be "no", but I can't seem to find any official documentation confirming that. A simple link to a Microsoft document would be an acceptable answer; an historical justification as to why such types are not supported would be an added bonus.
Upvotes: 6
Views: 19966
Reputation: 11
There is the option of passing hex values into a Long type which would be stored as unsigned as long as the sign bit is not part of the value. so for example,
&HFFFF = -1
but &HFFFF& = 65535
note that these 16bit vals are passed into a Long type, which is 32bits. so the sign bit is untouched. but if you need 32bits one suggestion was to use type Double, someone mentioned it before.
Regarding the need for unsigned types in general, an Unsigned Long would be a 32bit binary, compared to a Byte that is only 8bits. Try to write 24bit registers via a serial port with Byte types.. :) my take is that in VBA the sign bit sits like a splinter in the way of bit logic..
in any case, I hope this helps someone.
cheers,
Norwood, MA
Upvotes: 1
Reputation: 55009
As Kris said, they're not supported, except for the Byte
datatype, which is only available as unsigned, as can be seen in this list of datatypes: Data Type Summary
The page mentions VBA, but it also mentions Visual Studio 6.0, and the supported data types were the same.
I don't think you'll find official documentation saying why they didn't add unsigned data types since that's usually the wrong way around in that it probably wasn't a case of "why shouldn't we support this" as much as "would it be worth the extra effort to add this".
Edited to mention the exception of the Byte
datatype as pointed out by MarkJ.
Upvotes: 9
Reputation: 329
No not supported for VB6 ,it was added as explained at this link in VB.NET.
Upvotes: 0
Reputation: 1840
Not supported.
Some good info regarding simulating them: http://www.vbforums.com/showthread.php?t=578430
Upvotes: 0