Where do I keep my data?

Yuliya

Active member
Joined
Nov 9, 2007
Messages
34
Programming Experience
Beginner
Hello,

I'm new to VB. My question probably sounds simple, but I haven't been able to find an answer.

I am working on a Windows form application. My first form is a welcome screen with a bunch of buttons. Each button leads to another form. Each form allows the user to view and manipulate some data. There are several forms that use the same data, but display it in a different way. I have classes that represent the data. For now, I am storing the data in files. (Eventually, I'm planning to use a database, after I figure this out...)

My question is, where do I create an instance of a class that would contain data? Do I create it in the main form, or in one of the other forms, or in a different place altogether?

For example, if I have ItemClass, and I need to load a list of items and display them in different views, do I create a list of ItemClass objects at loading time in the main form? Do I make this list a public member of the form so it would be accessible to other forms that need to display it?

Thank you very much.
 
You create objects where they need to be used. You wouldn't create an object in the main form if it's only going to be used in a child form. If it needs to be used in both then you'd create it in the main form and pass a reference to the child from when it's created.
 
Back
Top