VB6支持无符号数据类型吗?
为了和一位同事打赌,我想知道VB6是否原生支持任何无符号数据类型。
我相信答案是“不”,但我似乎找不到任何官方文件证实这一点。一个指向 Microsoft 文档的简单链接就是一个可以接受的答案;关于为什么不支持此类类型的历史理由将是一个额外的好处。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
正如 Kris 所说,除了
Byte
数据类型之外,它们不受支持,该数据类型仅作为无符号可用,如以下数据类型列表所示:数据类型摘要该页面提到了 VBA,但也提到了 Visual Studio 6.0,并且支持的数据类型相同。
我认为您不会找到官方文档说明为什么他们不添加无符号数据类型,因为这通常是错误的方式,因为它可能不是“为什么我们不应该支持这个”的情况,而是“是否值得付出额外的努力来添加这个”。
编辑提及 MarkJ 指出的 Byte 数据类型的例外情况。
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 SummaryThe 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.唯一的无符号整数类型是 Byte。
The only unsigned integer type is Byte.
可以选择将十六进制值传递到 Long 类型,只要符号位不是值的一部分,该类型就会存储为无符号。例如,
请注意这些 16 位值被传递到 Long 类型,即 32 位。所以符号位保持不变。但如果你需要 32 位,一个建议是使用 Double 类型,之前有人提到过。
一般而言,考虑到对无符号类型的需求,Unsigned Long 将是 32 位二进制,而 Byte 则只有 8 位。尝试通过串行端口使用字节类型写入24位寄存器..:)我的看法是,在VBA中,符号位就像位逻辑方式中的碎片一样..
无论如何,我希望这对某人有帮助。
干杯,
诺伍德,马萨诸塞州
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,
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
不支持。
有关模拟它们的一些好信息: http://www.vbforums.com/showthread.php? t=578430
Not supported.
Some good info regarding simulating them: http://www.vbforums.com/showthread.php?t=578430
VB6 不支持,它是按照此
No not supported for VB6 ,it was added as explained at this link in VB.NET.