|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
"Global" objectsthat 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.)? 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 Show quoteHide quote "BobRoyAce" <b***@omegasoftwareinc.com> schreef in bericht news:1150082851.379731.81830@i40g2000cwc.googlegroups.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.)? > 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. 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 Show quoteHide quote "BobRoyAce" <b***@omegasoftwareinc.com> schreef in bericht news:1150091206.418178.141330@f6g2000cwb.googlegroups.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. > 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.
richtextbox changing fontstyles for selected text
is it possible to get delegates from properties directly? line breaks control types Parsing the appended data of log file in real time XML-RPC richtextbox selectedtext bold upper .... how to find out Tabindex is driving me nuts!!! actions done twice but only one trigger? Screen coordinates of selected datagridview cells left and top borders |
|||||||||||||||||||||||