What is the difference between #const and const?
This is # for conditional compilation. If you want to conditionally compile a certain piece of code, you can use #. For example:
#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/ the link gives a good description of conditional compilation.
http://www.utteraccess.com/wiki/index.php/Conditional_Compilation has some good inputs too.
source to share
Const
is your usual "normal" constant declaration.
#Const
different, it allows you to define constants specifically for use with type compiler directives #If
.
The "regular" constant will not be available to the compiler for conditional compilation:
Const DEBUG As Boolean = True
However, this:
#Const DEBUG = True
source to share