Use #Const to define the constant : Compiler Directive « Language Basics « VBA / Excel / Access / Word






Use #Const to define the constant

 

#Const UseEventLog = True

Private Sub DebugPrint(ByVal Source As String, ByVal Message As String)
    #If UseEventLog Then
      Call EventLog.WriteEntry("Source: " & Source & " Message: " & Message)
    #Else
      Debug.Print "Source: " & Source & " Message: " & Message
    #End If
End Sub

 








Related examples in the same category

1.Use string text value as the compiler directive
2.With the compiler directive
3.Use #If