I have a project that contains a usercontrol, some forms and a module.
The only thing in the module is one variable that is there so that it can be
used by the control and all the forms.
Couldn't I put the variable in the usercontrol and somehow set it so that it
can be used by usercontrol and all the forms?
If so, how?
Thanks 7 1057
" Just Me" <gr****@a-znet.com> schrieb: I have a project that contains a usercontrol, some forms and a module.
The only thing in the module is one variable that is there so that it can be used by the control and all the forms.
Couldn't I put the variable in the usercontrol and somehow set it so that it can be used by usercontrol and all the forms?
You can add a property to the form or usercontrol and then pass around a
reference to the {form, usercontrol}'s instance in order to be able to
access the property.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
I do use that trick (thanks to previous help from you) but I'm now wondering
what is special about a variable declared in a module. Whatever is special
about a variable in a module by default, can't I explicitly create such a
variable in a class.
Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OG**************@TK2MSFTNGP14.phx.gbl... " Just Me" <gr****@a-znet.com> schrieb:I have a project that contains a usercontrol, some forms and a module.
The only thing in the module is one variable that is there so that it can be used by the control and all the forms.
Couldn't I put the variable in the usercontrol and somehow set it so that it can be used by usercontrol and all the forms?
You can add a property to the form or usercontrol and then pass around a reference to the {form, usercontrol}'s instance in order to be able to access the property.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
A module is just a VB syntax convenience for a class with only static (read
Shared members).
So
Module Test
Public A As String
Public B As String
End Module
is the same as
Class Test
Public Shared A As String
Public Shared B As String
End Class
In either case, you can refer to Test.A. So you can do the same thing in a
class as a module. You'll find when you look around the Framework, that this
feature is used in lots of places. Just for a start, the
System.Windows.Forms.MessageBox class has a Shared Show method.
HTH
Nigel Armstrong
"Just Me" wrote: I do use that trick (thanks to previous help from you) but I'm now wondering what is special about a variable declared in a module. Whatever is special about a variable in a module by default, can't I explicitly create such a variable in a class.
Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:OG**************@TK2MSFTNGP14.phx.gbl..." Just Me" <gr****@a-znet.com> schrieb:I have a project that contains a usercontrol, some forms and a module.
The only thing in the module is one variable that is there so that it can be used by the control and all the forms.
Couldn't I put the variable in the usercontrol and somehow set it so that it can be used by usercontrol and all the forms?
You can add a property to the form or usercontrol and then pass around a reference to the {form, usercontrol}'s instance in order to be able to access the property.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
I was hoping that was true.
At first I thought I was going to say:
The example is a little different because there you use the class name and
the method.
Here we want to use only the variable name.
But I'm guessing that within a module you don't need the class name for
static variables. Is that the way to say it or is there a more general rule?
Thanks
"Nigel Armstrong" <Ni************@discussions.microsoft.com> wrote in
message news:B7**********************************@microsof t.com... A module is just a VB syntax convenience for a class with only static (read Shared members).
So
Module Test Public A As String Public B As String End Module
is the same as
Class Test Public Shared A As String Public Shared B As String End Class
In either case, you can refer to Test.A. So you can do the same thing in a class as a module. You'll find when you look around the Framework, that this feature is used in lots of places. Just for a start, the System.Windows.Forms.MessageBox class has a Shared Show method.
HTH
Nigel Armstrong
"Just Me" wrote:
I do use that trick (thanks to previous help from you) but I'm now wondering what is special about a variable declared in a module. Whatever is special about a variable in a module by default, can't I explicitly create such a variable in a class.
Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:OG**************@TK2MSFTNGP14.phx.gbl... >" Just Me" <gr****@a-znet.com> schrieb: >>I have a project that contains a usercontrol, some forms and a module. >> >> The only thing in the module is one variable that is there so that it >> can >> be used by the control and all the forms. >> >> Couldn't I put the variable in the usercontrol and somehow set it so >> that >> it can be used by usercontrol and all the forms? > > You can add a property to the form or usercontrol and then pass around > a > reference to the {form, usercontrol}'s instance in order to be able to > access the property. > > -- > Herfried K. Wagner [MVP] > <URL:http://dotnet.mvps.org/> >
REVISED changed module to project to make it clearer
" Just Me" <gr****@a-znet.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... I was hoping that was true.
At first I thought I was going to say: The example is a little different because there you use the class name and the method. Here we want to use only the variable name.
But I'm guessing that within a project you don't need the class name for static variables. Is that the way to say it. Is there a more general statement?
Thanks
"Nigel Armstrong" <Ni************@discussions.microsoft.com> wrote in message news:B7**********************************@microsof t.com...A module is just a VB syntax convenience for a class with only static (read Shared members).
So
Module Test Public A As String Public B As String End Module
is the same as
Class Test Public Shared A As String Public Shared B As String End Class
In either case, you can refer to Test.A. So you can do the same thing in a class as a module. You'll find when you look around the Framework, that this feature is used in lots of places. Just for a start, the System.Windows.Forms.MessageBox class has a Shared Show method.
HTH
Nigel Armstrong
"Just Me" wrote:
I do use that trick (thanks to previous help from you) but I'm now wondering what is special about a variable declared in a module. Whatever is special about a variable in a module by default, can't I explicitly create such a variable in a class.
Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:OG**************@TK2MSFTNGP14.phx.gbl... >" Just Me" <gr****@a-znet.com> schrieb: >>I have a project that contains a usercontrol, some forms and a module. >> >> The only thing in the module is one variable that is there so that it >> can >> be used by the control and all the forms. >> >> Couldn't I put the variable in the usercontrol and somehow set it so >> that >> it can be used by usercontrol and all the forms? > > You can add a property to the form or usercontrol and then pass around > a > reference to the {form, usercontrol}'s instance in order to be able to > access the property. > > -- > Herfried K. Wagner [MVP] > <URL:http://dotnet.mvps.org/> >
I was hoping that was true.
At first I thought I was going to say:
The example is a little different because there you use the class name and
the method.
Here we want to use only the variable name.
But I'm guessing that within a module you don't need the class name for
static variables. Is that the way to say it or is there a more general rule?
Thanks
"Nigel Armstrong" <Ni************@discussions.microsoft.com> wrote in
message news:B7**********************************@microsof t.com... A module is just a VB syntax convenience for a class with only static (read Shared members).
So
Module Test Public A As String Public B As String End Module
is the same as
Class Test Public Shared A As String Public Shared B As String End Class
In either case, you can refer to Test.A. So you can do the same thing in a class as a module. You'll find when you look around the Framework, that this feature is used in lots of places. Just for a start, the System.Windows.Forms.MessageBox class has a Shared Show method.
HTH
Nigel Armstrong
"Just Me" wrote:
I do use that trick (thanks to previous help from you) but I'm now wondering what is special about a variable declared in a module. Whatever is special about a variable in a module by default, can't I explicitly create such a variable in a class.
Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:OG**************@TK2MSFTNGP14.phx.gbl... >" Just Me" <gr****@a-znet.com> schrieb: >>I have a project that contains a usercontrol, some forms and a module. >> >> The only thing in the module is one variable that is there so that it >> can >> be used by the control and all the forms. >> >> Couldn't I put the variable in the usercontrol and somehow set it so >> that >> it can be used by usercontrol and all the forms? > > You can add a property to the form or usercontrol and then pass around > a > reference to the {form, usercontrol}'s instance in order to be able to > access the property. > > -- > Herfried K. Wagner [MVP] > <URL:http://dotnet.mvps.org/> >
REVISED changed module to project to make it clearer
" Just Me" <gr****@a-znet.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... I was hoping that was true.
At first I thought I was going to say: The example is a little different because there you use the class name and the method. Here we want to use only the variable name.
But I'm guessing that within a project you don't need the class name for static variables. Is that the way to say it. Is there a more general statement?
Thanks
"Nigel Armstrong" <Ni************@discussions.microsoft.com> wrote in message news:B7**********************************@microsof t.com...A module is just a VB syntax convenience for a class with only static (read Shared members).
So
Module Test Public A As String Public B As String End Module
is the same as
Class Test Public Shared A As String Public Shared B As String End Class
In either case, you can refer to Test.A. So you can do the same thing in a class as a module. You'll find when you look around the Framework, that this feature is used in lots of places. Just for a start, the System.Windows.Forms.MessageBox class has a Shared Show method.
HTH
Nigel Armstrong
"Just Me" wrote:
I do use that trick (thanks to previous help from you) but I'm now wondering what is special about a variable declared in a module. Whatever is special about a variable in a module by default, can't I explicitly create such a variable in a class.
Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:OG**************@TK2MSFTNGP14.phx.gbl... >" Just Me" <gr****@a-znet.com> schrieb: >>I have a project that contains a usercontrol, some forms and a module. >> >> The only thing in the module is one variable that is there so that it >> can >> be used by the control and all the forms. >> >> Couldn't I put the variable in the usercontrol and somehow set it so >> that >> it can be used by usercontrol and all the forms? > > You can add a property to the form or usercontrol and then pass around > a > reference to the {form, usercontrol}'s instance in order to be able to > access the property. > > -- > Herfried K. Wagner [MVP] > <URL:http://dotnet.mvps.org/> >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: YGeek |
last post by:
Is there any difference between declaring a variable at the top of a method
versus in the code of the method? Is there a performance impact for either
choice? What about if the method will return...
|
by: James A. Donald |
last post by:
I am contemplating getting into Python, which is used by engineers I
admire - google and Bram Cohen, but was horrified to read
"no variable or argument declarations are necessary."
Surely that...
|
by: Lucy |
last post by:
In the Declarations section of a form's code module, what is the difference
between the following:
Dim Flag As Boolean
Public Flag As Boolean
Private Flag As Boolean
Thanks!
|
by: Brian |
last post by:
If i declare a module level oledbconnection with each
request for the page, the variable remains in scope? I get
open.executing error message on subsequent calls for the
page.
I assumed ASP.Net...
|
by: bnob |
last post by:
I have to keep a variable (integer) during the navigation of my asp.net
project (vb.net code behind).
So actually I use a module where I declare a global variable
Public MyGlobalVariable as...
| |
by: GinTon |
last post by:
How to access to a variable (that value is not returned) from a module
imported?
And the variable is set at the module-level.
That module is external to my program, it's from another project so...
|
by: Jeff |
last post by:
Still new to vb.net in VS2005 web developer...
What is the proper/standard way of doing the following - setting the value
of a variable in one sub and
calling it from another? E.g., as below....
|
by: noagbodjivictor |
last post by:
I have a variable names actions in a module named qt_actions.py
Well this is what I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object...
|
by: MMcCarthy |
last post by:
We often get questions on this site that refer to the scope of variables and where and how they are declared. This tutorial is intended to cover the basics of variable scope in VBA for MS Access. For...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |