Solved

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

Posted on 2008-10-30
2
357 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio .Net 2012 and Crystal Reports 9 67
Get Client IP on RDS - VB.NET 15 45
Store results in vb.net 3 20
vb.net and creating a class 5 16
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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 …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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