gpt4 book ai didi

vba - #const 和 const 有什么区别?

转载 作者:行者123 更新时间:2023-12-01 12:33:16 25 4
gpt4 key购买 nike

This class, which runs just fine包含类似 #Const UseScriptingDictionaryIfAvailable = True 的行。我通常使用 Const UseScriptingDictionaryIfAvailable As Boolean = True

我注意到您不能使用#const 显式声明类型。而 As Boolean 在后者中是可选的,在前者中是禁止的。这是唯一的区别吗?有内部差异吗?

最佳答案

# 用于条件编译。如果要有条件地编译某段代码,可以使用#。例如:

#Const MyEnv = "Testing"

Sub TestMacro()

#If MyEnv = "Testing" Then
' do something here
Debug.Print "Logging for testing"
Dim X as String
X = "..."
#Else
Dim Y as Int
Y = 100
#End If

End Sub

https://usefulgyaan.wordpress.com/2013/06/26/vba-trick-of-the-week-conditional-compiling/链接很好地描述了条件编译。

http://www.utteraccess.com/wiki/index.php/Conditional_Compilation还提供了一些很好的输入。

关于vba - #const 和 const 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31578442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com