在Visual Basic中取消定义一个常量。

huangapple go评论49阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年6月8日 07:13:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76427635.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定