英文:
Undefine a constant in Visual Basic
问题
In C#, conditional compilation symbols can be undefined (removed) with:
#undef SYMBOL_1
// ...
#if SYMBOL_1
ThisDoesNotRun();
#else
ButThisDoesRun();
#endif
Visual Basic has something similar called "Constants":
#Const VB_SYMBOL_1 = True
' ...
#If VB_SYMBOL_1
ThisWillRun()
#End If
#If Not VB_SYMBOL_1
ButThisWillNot()
#End If
Visual Basic does not have a direct equivalent of #undef
in C#. You can redefine the constant with #Const VB_SYMBOL_1 = False
, but this is not the same thing.
英文:
In C#, conditional compilation symbols can be undefined (removed) with:
#undef SYMBOL_1
// ...
#if SYMBOL_1
ThisDoesNotRun();
#else
ButThisDoesRun();
#endif
Visual Basic has something similar called "Constants":
#Const VB_SYMBOL_1 = True
' ...
#If VB_SYMBOL_1
ThisWillRun()
#End If
#If Not VB_SYMBOL_1
ButThisWillNot()
#End If
Does VB have functionality to undefine a constant, like undef
in C#?
You can redefine the constant with #Const VB_SYMBOL_1 = False
, but this is not the same thing.
答案1
得分: 0
这个答案来自对问题的评论(感谢 Hans)。要取消定义预处理器常量,请使用:
#Const VB_SYMBOL_1 = Nothing
英文:
This answer is from a comment to the question (thanks Hans). To undefine a preprocessor constant use:
#Const VB_SYMBOL_1 = Nothing
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论