整数VS朗混乱 [英] Integer Vs Long Confusion

查看:110
本文介绍了整数VS朗混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到许多人认为在以下

I have seen many believe in the following

VBA将所有整数值输入长

在事实上,即使是 MSDN文章说:

In fact, even the MSDN article says

在最近的版本,但是,VBA将所有整数值long类型,即便是类型整数声明。

这怎么可能呢?考虑一个简单的例子。

How is this possible? Consider this simple example.

Sub Sample()
    Dim I As Integer
    I = 123456789
End Sub

如果 VBA 将所有整数值键入 即便是作为整数类型,然后在上面不应该给你的溢出错误!

If VBA converts all Integer values to type Long even if they're declared as type Integer, then the above should never give you the Overflow error!

我在想什么吗?或者我应该把它的说法是不正确的,予以严重理会该链接说,在开始

What am I missing here? Or should I take it that the statement is incorrect and pay serious heed to that the link says in the beginning

此内容已不再积极的维护,它被设置为,对于谁可能仍然在使用这些技术,用任何保证或精度要求有关最新的产品版本和服务发布任何人。

注意:我加入了标签 Excel的VBA /简报 - VBA /字VBA /接入VBA 希望一个VBA专家看看这情况下,专家不监视在 VBA 标记。一旦解决方案已在寻找我会删除这些不必要的标签。

NOTE: I am adding the tags Excel-VBA/Powerpoint-VBA/Word-VBA/Access-VBA hoping a VBA expert to have a look at this in case the expert doesn't monitor just the VBA tag. I will remove these unnecessary tags once a solution has been sought.

推荐答案

声明为一个整数仍是类型检查作为整数一个整数。 MSDN文档的引用变量如何在内部存储。在32位的系统中,一个Integer将存储在32个字节,而在一个16比特系统中,它会被储存在16因此,最大尺寸。

An integer declared as an Integer is still type checked as an Integer. The msdn documentation is referencing how the variable is stored internally. On a 32 bit system, an Integer will be stored in 32 bytes, while on a 16 bit system, it would have been stored in 16. Hence the maximum size.

没有类型转换回事就VBA而言。一个int是一个int和长很长,即使他们现在采取了一样多的空间

There is no type conversion going on as far as VBA is concerned. An int is an int and a long is a long, even though they now take up just as much space.

这篇关于整数VS朗混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆