"Reynaert Kristien" wrote:
> Hi,
>
> I need some kind of unbound table in which i can add and edit items
> I must be able to read items by ID and update some fieldvalues.
> At the end of the program i will have to read all items of this table and
> use the values to update some "real" (other) tables
> So i need some kind of 'worktable' to store my data temporary
>
> I think i have to make a class in which i define my fields of my worktable
> and then work with some collection of that class, but i don't quite know
> exactly how to do this
>
> Someone who can give me some hints in what i should use?
> Thanks,
> Kristien
>
You would have a public class with public properties.
<http://www.vbdotnetheaven.com/Uploadfile/rajeshvs/PropertiesInVbDotNet04192005060237AM/PropertiesInVbDotNet.aspx>
You would instanciate the class new an object and set the object's public
properties each time.
You can use a List<T> a collection.
dim myobjects = new List<MyObject>
If the object/class was named MyObject, then in some kind of loop to load
the object into the collection.
dim obj = new MyObject
obj.ID = 1
obj.Name = "help"
myobjects.add(myobjects)
Now MyObject iis in a collection of objects myobjects.
If you have .Net 3.0 Framework or better, the you can use Linq to query the
collection for a MyObject in myobjects by ID as an example and make the
chenges to the object.
If you don't have Linq, then you'll need to make an function or method to
address the object in the collection using a foreach loop
..
foreach(myobject in myobjects)
if myobejct.ID = passedID then
myobject.Name = "Help"
endif
You would walk the collection using a loop to read each object in the
collection to sent to a SQL table or whatever.
foreach(myobject in myobjects)
TableNameField = myobject.Name
It's an example of of OOP's Object Oriented Programming.
You don't need a worktable, but instead you need to understand OOP's,
gernerics and collections.
|