变量的适当位置 [英] proper place for a variable
问题描述
您好,
我需要在所有应用程序特定表单和类中使用一个特定值
我的应用程序。什么是适当的地方?目前我使用带有公共常量的
模块,这似乎是一个方便的地方。传递它
作为参数似乎并不是非常有效。你有什么建议?
谢谢
Frank
Hello,
I need one specific value in all the applicationspecific forms and classes
of my application. What is the proper place to put it? At the moment I use a
module with a public constant and that seems to be a handy place. Passing it
as a parameter doesn''t seem to be very efficient. What do you suggest?
Thanks
Frank
推荐答案
弗兰克 < FR *** @ frank.com>在消息中写道
news:cc ********** @ news3.tilbu1.nb.home.nl ...
"Frank" <fr***@frank.com> wrote in message
news:cc**********@news3.tilbu1.nb.home.nl...
你好,
我需要在我的应用程序的所有特定于应用程序的表单和类中使用一个特定值。什么是适当的地方?目前我使用
一个带有公共常量的模块,这似乎是一个方便的地方。传递
它作为参数似乎并不是非常有效。你有什么建议吗?
谢谢
弗兰克
Hello,
I need one specific value in all the applicationspecific forms and classes
of my application. What is the proper place to put it? At the moment I use a module with a public constant and that seems to be a handy place. Passing it as a parameter doesn''t seem to be very efficient. What do you suggest?
Thanks
Frank
我相信其他人会有不同的意见,但这里有...
即使允许全局变量是一个明确的非OO功能,从以前的VB版本带来了前面的
,我很想完全按照
你现在在做什么我不同意它是否是变量而不是名为常量的
,但我认为全局命名常量没有坏处。
-
彼得[MVP视觉开发者]
所有行业的杰克,无人掌握。
I''m sure others will have contrasting opinions, but here goes...
Even though allowing global variables is a decidedly non-OO feature brought
forward from previous VB versions, I would be very tempted to do exactly as
you are now doing. I would not agree if it were a variable instead of a
named constant, but I see no harm in a global named constant.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
记住,模块是一个''密封''类自动导入,所有
成员和属性都是''共享''。
就个人而言,我避免使用模块和显式使用类,这个
避免了模块周围的所有混淆。
HTH
-
OHM(特里伯恩斯)
。 。 。单手人。 。
当你不知道自己在做什么时,过得很快
Peter van der Goes < p _ ********** @ toadstool.u>在消息中写道
新闻:Oi ************* @ TK2MSFTNGP11.phx.gbl ...
Remember, a module is a ''Sealed'' Class which in imported automatically, all
members and properties are ''Shared''.
Personally, I avoid Modules and perfer to explicitly use Classes, this
avoids all the confusion surrounding Modules.
HTH
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don''t know what you''re doing
"Peter van der Goes" <p_**********@toadstool.u> wrote in message
news:Oi*************@TK2MSFTNGP11.phx.gbl...
"弗兰克" < FR *** @ frank.com>在消息中写道
新闻:cc ********** @ news3.tilbu1.nb.home.nl ...
"Frank" <fr***@frank.com> wrote in message
news:cc**********@news3.tilbu1.nb.home.nl...
你好,
我需要一个我的应用程序的所有应用程序特定表单和
类中的特定值。什么是适当的地方?目前我
Hello,
I need one specific value in all the applicationspecific forms and classes of my application. What is the proper place to put it? At the moment I
使用带有公共常量的
use a
模块,这似乎是一个方便的地方。
module with a public constant and that seems to be a handy place.
传递它
作为参数似乎并不是非常有效。你有什么建议?
谢谢
弗兰克
我相信其他人会有不同意见,但这里有...
即使允许全局变量是从以前的VB版本中提出一个明确的非OO功能
as a parameter doesn''t seem to be very efficient. What do you suggest?
Thanks
Frank
I''m sure others will have contrasting opinions, but here goes...
Even though allowing global variables is a decidedly non-OO feature
,我很想做你现在正在做的
。我不同意它是否是变量而不是命名常量,但我认为全局命名常量没有坏处。
-
Peter [MVP Visual Developer]
所有行业的杰克,无人掌握。
brought forward from previous VB versions, I would be very tempted to do exactly
as you are now doing. I would not agree if it were a variable instead of a
named constant, but I see no harm in a global named constant.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
你应该在一个类中声明你的公共常量,让GLOBALS
公共类GLOBALS
Public Const PI As Double = 3.142
结束班
Dim a As Double = GLOBALS.PI
-
OHM(Terry Burns)
。 。 。单手人。 。
当你不知道自己在做什么时,过得很快
Frank < FR *** @ frank.com>在消息中写道
news:cc ********** @ news3.tilbu1.nb.home.nl ...
You should declare your public constants in a class, lets GLOBALS
Public Class GLOBALS
Public Const PI As Double = 3.142
End Class
Dim a As Double = GLOBALS.PI
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don''t know what you''re doing
"Frank" <fr***@frank.com> wrote in message
news:cc**********@news3.tilbu1.nb.home.nl...
你好,
我需要在我的应用程序的所有特定于应用程序的表单和类中使用一个特定值。什么是适当的地方?目前我使用
一个带有公共常量的模块,这似乎是一个方便的地方。传递
它作为参数似乎并不是非常有效。你有什么建议?
谢谢
弗兰克
Hello,
I need one specific value in all the applicationspecific forms and classes
of my application. What is the proper place to put it? At the moment I use a module with a public constant and that seems to be a handy place. Passing it as a parameter doesn''t seem to be very efficient. What do you suggest?
Thanks
Frank
这篇关于变量的适当位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!