vba $符号在VBA中有什么作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3389444/
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
What does the $ symbol do in VBA?
提问by l--''''''---------''''''''''''
For example:
例如:
variable1=Dir$(some_path)
vs.
对比
variable1=Dir(some_path)
What is the difference?
有什么不同?
Why not just do:
为什么不这样做:
variable1=string(Dir(some_path))
回答by Gerhard Powell
Here is a Cheat Sheet for DataTypes
这是数据类型的备忘单
Variable End with:
变量结尾为:
$ : String
% : Integer (Int16)
& : Long (Int32)
! : Single
# : Double
@ : Decimal
Start with:
从...开始:
&H : Hex
&O : Octal
Comparison between VB and VB.Net (reference)
VB和VB.Net的比较(参考)
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 Jason Evans
I think that the $version returns a String, and the non $version returns a variant.
我认为$版本返回 a String,非$版本返回 a variant。
http://forums.devarticles.com/microsoft-access-development-49/mid-function-vs-mid-26315.html
http://forums.devarticles.com/microsoft-access-development-49/mid-function-vs-mid-26315.html
回答by LittleBobbyTables - Au Revtheitroad
The dollar sign indicates a string will be returned instead of a variant.
美元符号表示将返回一个字符串而不是一个变体。
回答by Dylan West
Dir() returns the result as the variant data type. Dir$() returns the result as the string data type.
Dir() 将结果作为变体数据类型返回。Dir$() 将结果作为字符串数据类型返回。
回答by Michael Buen
some uses $ version for its purported efficiency(as it accepts and outputs statically-typed variables only). I don't know how much is the speed difference between statically-typed and variant type, just benchmark
有些使用 $ 版本来达到其声称的效率(因为它只接受和输出静态类型的变量)。不知道静态类型和变体类型的速度差异有多大,只是基准

