如何使常量可用于整个应用程序? [英] How to make constants available for the whole application?
问题描述
我需要为整个应用程序提供一组常量。
公共const仅限于声明常量的形式。
有没有声明一次和所有表格的方法可以访问常数值吗?
谢谢
比尔
" Bill Nguyen" <双***************** @ jaco.com>在消息新闻中写道:你
************* @ TK2MSFTNGP12.phx.gbl ...我需要使一组常量可用于整个应用程序。
公共const仅限于声明常量的形式。
有没有办法声明一次,所有表单都可以访问常量值?
谢谢
比尔
将它们放入标准模块中。
< blockquote>" Bill Nguyen" <双***************** @ jaco.com> schrieb:
我需要为整个
应用程序创建一组常量。
公共const仅限于声明常量的形式。
有没有办法申报一次,所有表格都可以访问常数
值?
如果你把它们放在一个班级,你必须符合资格常量'的名称
,包含常量定义的类的名称(例如
''Form1.Constant1'')。或者你可以将常量放在一个模块
中,以便能够在没有明确资格的情况下访问它们。
-
MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http:// classicvb。 org / petition />
I need to make a set of constants to be available for the whole application.
Public const is confined to the form from which constants are declared.
Is there a way to declare once and all forms can access the constant values?
Thanks
Bill
"Bill Nguyen" <bi*****************@jaco.com> wrote in message news:u
*************@TK2MSFTNGP12.phx.gbl...I need to make a set of constants to be available for the whole application.
Public const is confined to the form from which constants are declared.
Is there a way to declare once and all forms can access the constant values?
Thanks
Bill
Place them in a standard module.
"Bill Nguyen" <bi*****************@jaco.com> schrieb:I need to make a set of constants to be available for the whole
application.
Public const is confined to the form from which constants are declared.
Is there a way to declare once and all forms can access the constant
values?
If you place them in a class, you will have to qualify the constant''s names
with the name of the class containing the constant definitions (e.g.
''Form1.Constant1''). Alternatively you can place the constants in a module
in order to be able to access them without explicit qualification.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
这篇关于如何使常量可用于整个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!