Solved

VB.NET console app needs to share it's module level public variables

Posted on 2008-10-30
2
356 Views
Last Modified: 2012-05-05
I have a console application that creates several objects which are instantiated classes which are part of the solution.  How can I share a console level variable between other class/dlls without passing the value into the class via something like sub new (myValues as someSetOfSharedValues)?

0
Comment
Question by:Howard Bash
2 Comments
 
LVL 15

Expert Comment

by:David L. Hansen
ID: 22847987
making the variables public will do it..but I'd suggest "Friend" (it's like public but a bit more secure).  The other idea is to use a database as the middleman between the different objects (if it makes sence to do that).
0
 
LVL 18

Accepted Solution

by:
Priest04 earned 500 total points
ID: 22848483
You showed an example that you want to pass variables through constructor. Yes, you can do that, just make a class constructor that accepts these variables.

Other way would be to have variables shared (static in c#). This can be done either by creating a shared class, or by creating a module, and having public fields (variables) in it. This fields will be visible everywhere in application, so you don't need to pass them in constructor.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Change data in datatable 8 31
Create XML 5 46
Visual Studio editor? 1 38
Change Format on Data when exporting to Excel 4 23
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now