在 VBA 中处理大于 Long 的数字

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1840661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 10:10:16  来源:igfitidea点击:

Handling numbers larger than Long in VBA

excelvbalargenumber

提问by Agent389

I am Currently trying to write some code in VBA to solve a problem from Project Euler. I have been trying to answer a question that requires you to find primes that can be divided into a number that will not fit in a long. Any suggestions as how to handle this problem?

我目前正在尝试用 VBA 编写一些代码来解决 Project Euler 中的一个问题。我一直在尝试回答一个问题,该问题要求您找到可以被整除为一个不能放入 long 的数字的质数。有关如何处理此问题的任何建议?

I know I can split the number between two variables and I have done that for addition and subtraction but never division. Any help will be appreciated.

我知道我可以在两个变量之间拆分数字,并且我已经这样做了加法和减法,但从来没有除法。任何帮助将不胜感激。

回答by Arnon

You can define a Decimal data type (12 Bytes), but only within a variant.

您可以定义十进制数据类型(12 字节),但只能在变体中定义。

Dim i As Variant

Dim i As Variant

i = CDec(i)

i = CDec(i)

回答by BrainO2

Use the "Double" data type that takes larger values.

使用采用更大值的“Double”数据类型。