Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi

i have a 3 tier windows aplication(VB.NET), and in my WINUI i have couple of shared variable. i need to read those shared variables from my BLL and DAL

 

how am i suppose to access those shared variables from BLL and DAL

 

Thank you

Posted

You can define a 4th project that has these shared variables defined within, reference this project from the other three, and have your UI create the initial instance of this 4th project, and let it live in your main form.

 

When you instantiate/call your BLL or DAL, pass the instance of the 4th project (by-reference) and these other layers can now use the shared variables.

 

There's other ways of doing this, this is just the first/easiest way that came to mind at 6:45am. ;)

Posted

I guess a kind of an extension/variation of mocella's answer would be to

* Define a 4th layer called WorkFlowLayer (WFL) or something

* Ensure that all the other layers are dependant on the WFL

* In the WFL, define a module (not a class) called modGlobalVars.

* Define the variables you will use in modGlobal Vars - eg: Public System_Mode As String

 

The beauty of defining modGlobalVars as a module rather than a class in this scenario is that it doesn't have to be instantiated before it's used.

  • Administrators
Posted

What kind of information does the shared variables contain - depending on their contents it may be easier to just pass this information between the application layers rather than relying on global variables which can often lead to hard to maintain code.

Also rather than using a module (which is only available in VB) use a class but declare the variables as shared - then you don't need to instantiate the class to access them.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...