Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Globals within class libraries

Posted on 2004-11-02
Medium Priority
Last Modified: 2010-04-24
I have a DLL project with muliple classes;  Data classes actually and all these use the same basic connection string.  Rather than define them separately for each class I tried this at the top of the file:

Dim ConnectString as String

But I get the error "Statement not valid within a namespace".  I understand why but what would be a workaround that will accomplish the same thing; maintain a value common to all the classes within the class library?

Question by:MIKEV
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 28

Assisted Solution

iboutchkine earned 200 total points
ID: 12474775
Cretae a module and add the global variables there

Accepted Solution

Ignacio Soler Garcia earned 800 total points
ID: 12474794
Create a class on the same DLL project called "Config" or "Global" or whatever and create public constants like:

Public Class Config

    Public Const connectionString as String = "PutHereTheText"

End Class

Then do an import of this class on the other classes

Imports Config


Askme more if you need it!


Author Comment

ID: 12474986
"Cretae a module and add the global variables there"

I've read the concept of modules in VB.Net will become obsolete, I'd rather not back myself into that corner, but it's currently a valid solution.

"Create a class on the same DLL project called "Config" or "Global" or whatever and create public constants like:"

That's it.  Perfect, thanks!!!
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Expert Comment

by:Ignacio Soler Garcia
ID: 12475055
Yeah, I have the luck of just being a vb.net programmer without having vb6 skills. I don't like anything that is not related with OOP :)
LVL 28

Expert Comment

ID: 12475067
Module is not absolete. Just in VB.NET it is Shared class. that is all

Expert Comment

by:Ignacio Soler Garcia
ID: 12475160
Okok, that's right, but in normal OOP you don't use to define shared classes aren't you?

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 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