473,396 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

"Global" objects

I posted the post below in another newsgroup and it has been suggested
that this may be a better place to post it. See below:

---ORIGINAL POST BEGINS---
I have an application which is comprised of, among many other things, a
Main form which shows various user controls depending on which NavBar
link they click on. In addition, there are many Entity classes that I
created to support the application, one of which happens to be called
User. In my main form I currently instantiate a User object which
corresponds
to the user who logged in. The User object that is created
(g_oCurrentUser) is declared as Private in my Main form's code, but
there is a Public function (GetCurrentUser) that returns a pointer to
g_oCurrentUser.

My question is "Is there a way for the other entity classes to "get at"
the
g_oCurrentUser object from the main form? The reason I need to do this
is because I want to pull the current user's ID to use for populating
the fkLastUpdatedByUserID field of the entities when they have been
changed by the current user.

Is there a way to do this? I guess my question, more generally, is how
can I have Object variables that are accessible both to the Main form
and to other parts of the system (e.g. user controls that will be
created later and shown on the form, other Objects, modules, etc.)?

Jun 12 '06 #1
4 1256
Bob,

You can use a shared class or a module (which is a shared class with less
documentive value).

It this is not what you want or if you don't know how, than please reply.

Cor

"BobRoyAce" <br**@omegasoftwareinc.com> schreef in bericht
news:11*********************@i40g2000cwc.googlegro ups.com...
I posted the post below in another newsgroup and it has been suggested
that this may be a better place to post it. See below:

---ORIGINAL POST BEGINS---
I have an application which is comprised of, among many other things, a
Main form which shows various user controls depending on which NavBar
link they click on. In addition, there are many Entity classes that I
created to support the application, one of which happens to be called
User. In my main form I currently instantiate a User object which
corresponds
to the user who logged in. The User object that is created
(g_oCurrentUser) is declared as Private in my Main form's code, but
there is a Public function (GetCurrentUser) that returns a pointer to
g_oCurrentUser.

My question is "Is there a way for the other entity classes to "get at"
the
g_oCurrentUser object from the main form? The reason I need to do this
is because I want to pull the current user's ID to use for populating
the fkLastUpdatedByUserID field of the entities when they have been
changed by the current user.

Is there a way to do this? I guess my question, more generally, is how
can I have Object variables that are accessible both to the Main form
and to other parts of the system (e.g. user controls that will be
created later and shown on the form, other Objects, modules, etc.)?

Jun 12 '06 #2
I don't know if that's what I need, but sounds like I would want one of
them. I don't know how to do either, though, so would appreciate
guidance including steps and code samples if at all possible (brief, of
course). I am brand new to VB.NET and am using Visual Studio 2005.

Jun 12 '06 #3
I don't know if that's what I need, but sounds like I would want one of
them. I don't know how to do either, though, so would appreciate
guidance including steps and code samples if at all possible (brief, of
course). I am brand new to VB.NET and am using Visual Studio 2005.

Jun 12 '06 #4
Bob,

You would not place values or objects that is for your complete project in
one UI (form)class as all classes could use it.

Therefore is the Shared Class (in fact it is placed on the mainstack of the
resulting endprogram, and therfore consumes constantly memory). In C
languages the name for this was Static, this word however does not so good
reflect the meaning, because the contents of everything is variable.
Therefore in VBNet it is Shared.

You can make this class as by instance below. (Just typed in so watch typos)

Public Shared Class TheClass 'MyClass is a special word
Private mTheField as String
Public Property TheField as String
Get
Retunr mField
End Get
Set ............. I forever forget this text it is autotyped
mField = value
End Set
End Class

This you can use in everywhere in your project by instance the mainfrm

me.Textbox1.text = TheClass.TheField

I hope this helps,

Cor

"BobRoyAce" <br**@omegasoftwareinc.com> schreef in bericht
news:11**********************@f6g2000cwb.googlegro ups.com...
I don't know if that's what I need, but sounds like I would want one of
them. I don't know how to do either, though, so would appreciate
guidance including steps and code samples if at all possible (brief, of
course). I am brand new to VB.NET and am using Visual Studio 2005.

Jun 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eddy Ilg | last post by:
Hi, I am having a problem with an application I am writing: I have 2 scripts called 'conf' and 'build'. Both define a variable named 'root' and import a module named 'helper'. In the...
7
by: Lyn | last post by:
Hi and Season's Greetings to all. I have a question regarding the use of a qualifier word "Global". I cannot find any reference to this in Access help, nor in books or on the Internet. "Global"...
5
by: j | last post by:
Anyone here feel that "global variables" is misleading for variables whose scope is file scope? "global" seems to imply global visibility, while this isn't true for variables whose scope is file...
9
by: Javaman59 | last post by:
I saw in a recent post the :: operator used to reach the global namespace, as in global::MyNamespace I hadn't seen this before, so looked it up in MSDN, which explained it nicely. My question...
4
by: BB | last post by:
Hello all, I might be missing something here, but am trying to understand the difference between using application-level variables--i.e. Application("MyVar")--and global variables--i.e. public...
2
by: Steve | last post by:
I am new to this newsgroup & to .NET in general. I have been playing around with Visual Studio .NET, building and rendering web pages using VB "code behind" files. My problem / question is; How...
8
by: Hans Greif | last post by:
Hallo, hello, i try to implement a global dataset - singleton based. On www.bakterienforum.de i found a singleton implementation: sealed class SingletonCounter { public int Counter = 0;
5
by: dave | last post by:
If I have a class that hold, for instance, user settings that should be accessible to the entire program logic, what is a good paradigm to use? In C++, I would have made it a global object,...
6
by: Anders J | last post by:
Hi We have some code that runs in a EventReceiver ItemAdded handler. The code must be thread-safe since it is iterating a List to find the max number of a column and assigns it + 1 to the Item...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.