Help with VS2008

Posted on 2009-05-01
Last Modified: 2013-11-26
Hi All!!
I have a VB6 app I am converting to .Net2008.  In VB6 I opened a form and hid it to reference values.  It contains information about the company such as name, address, minimum statement balances, credit card processor, and such like.
I would like to do the same thing in my 2008 app but I feel there is a much better way to do this than opening a form and hiding it. I don't know what it is but with some help from you guys I'll bet we can figure some thing out.  

Thanks for your help!!!

Question by:JDL129
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    Typically you create a custom Class to hold your values and then pass a reference to an instance of that class around.  If you need only ONE instance of the class across the entire application then you could make it Shared.

    It might be helpful to know WHERE the data is being passed from and to...then we can give a more specific example.

    Author Comment

    Idle Mind!!!!
    What I would like to do is fill this 'Class' when the application opens.  I will be getting the data from a table in the main dataset in the app.  It is called tblCompany and stores all of the information about the company.  I guess I would like to pass this data to a 'Class'? There are about 20 forms in this app that at times would require pieces of the data from the 'Class'.  How would I create and fill the 'Class' and how would I instantiate the 'Class' and retreive the pieces of data that I need such as the company name, address, tax rate, DEA, Phone, PharmacyLicense, etc.
    As you can tell from my question I am pretty new at this so gentle!!!  :-)

    Thanks for your response!!

    LVL 85

    Accepted Solution

    "What I would like to do is fill this 'Class' when the application opens."

    So it really sounds like you only ever need ONE set of data on a "company" at any given time.  A SHARED class will make this quite easy:

        Public Class Company

            Public Shared Name As String
            Public Shared Address As String
            Public Shared TaxRate As Double
            ' etc...

        End Class

        Public Class Form1

            Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                Company.Name = "Idle_Mind"
                Company.Address = "Experts Exchange"
                Company.TaxRate = 4.11
            End Sub

        End Class

    Note that you can access the SHARED values in Company from ANYWHERE in your application!

    Author Closing Comment

    IM YOU ARE THE MAN!!!!!!!!!!!!!!!!!!!!!!!!
    Thanks for your help, it was exactly what I needed!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 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

    14 Experts available now in Live!

    Get 1:1 Help Now