Excel VBA 英镑和冒号符号的含义?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7649101/
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-11 14:10:49  来源:igfitidea点击:

Excel VBA Pound and Colon Signs Meaning?

excelvbaexcel-vba

提问by Shankar ARUL - jupyterdata.com

I am trying to understand a vba function with the pound and colon symbol interspersed throughout it.

我试图理解一个带有磅和冒号符号的 vba 函数。

VBA function:

VBA 函数:

kn = 1#: pn = 1#:  y = 1#

I know the pound sign is used to declare a variable as a double in Excel VBA. However, it does not seem to make any sense in terms of the above line. What does the above function do?

我知道英镑符号用于在 Excel VBA 中将变量声明为双精度值。但是,就上述行而言,它似乎没有任何意义。上面的函数有什么作用?

回答by Romain

The colon (:) is a statement delimiter. It would be equivalent to a new line in VBA, or a semicolon in C (just to quote a random example). It allows you to write several instructions on a single line rather than going to a new line each time.

冒号 ( :) 是语句分隔符。它相当于 VBA 中的新行,或 C 中的分号(仅引用一个随机示例)。它允许您在一行上编写多个指令,而不是每次都转到新行。

The pound (#) is a short-hand type specifier that forces your literals to be double, so basically 1#is almost equivalent to 1.0.

磅 ( #) 是一种速记类型说明符,它强制您的文字为double,因此基本上1#几乎等同于1.0.

回答by Gerhard Powell

****Here is a Cheat Sheet for DataTypes ****

****这是数据类型的备忘单****

Variable End with:

变量结尾为:

$ : String
% : Integer (Int32)
& : Long (Int64)
! : Single
# : Double
@ : Decimal

Start with:

从...开始:

&H : Hex
&O : Octal

Visual Studio .Net added Literal Types (reference)

Visual Studio .Net 添加了文字类型(参考

Value End with: (For more complete list, refer the the reference)

值结尾为:(更完整的列表,请参阅参考)

S : Short (Int16)
I : Integer (Int32)
L : Long (Int64)
F : Single
R : Double
D : Decimal

回答by Keith Borrowman

Building off Romain's response, kn = 1#: pn = 1#: y = 1#is equivalent to:

建立罗曼的回应, kn = 1#: pn = 1#: y = 1#相当于:

kn = 1#
pn = 1#
y = 1#