I would like to have a file in my project which contains variables for use by all classes. I this possible to accomplish efficiently. I have heard that using a module with static varibles could work.

Recommended Answers

All 3 Replies

I'm not sure I understand. Classes shouldn't be using external variables. If you have a file which defines variables and they are used by multiple classes then you are making the inner workings of the classes dependent on external variables. If I've completely missed the point then please elaborate.

commented: Modules should be eliminated from VB.NET +14

I am sorry that I worded my question incorrectly. I am just looking for the best way to store data that I may change in my program, in a central location. Imagine it like an internal configuration file.

You can store data in a file and read/write as required. You can also store data in Settings variables. The Settings variables can be defined as app specific (one variable per app) or per user (each user gets a copy of the variable). Values can be read by

localcopy = My.Settings.variable

and written (saved) by reversing the order of the assignment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.