User1588557281 posted
Hello, beeing new, I apologize, if my words are not very clear
My Question:
within VB.Net I create a class "Brett" (for tests very simple. the class contains only a property "length").
now it is possible, to gather the objects in a list of objects Brett with "Private Dim row As New List(Of Brett)". This works with row.add( ... ) o.k
Now the objects Brett in each row may have different length and in each row may have a different number of entries . works.
BUT:
now I would like to have a class "clsROW" (not a list of object like above).
So, is it possible, to declare and use a class clsROW with property "row" as above, says with a propety .....List(of ?
Reason: I would like to gather the rows again in a "Private Dim room As New List(Of row)"
(if this works, I surely would try to make a class clsROOM to gahter the rows within room)
I can write the program without this clsROW and so on, but trying tu understand objects within VB.net (objects at all :-) ), I would prefer to consequently use objects, where possible
Now I add the code snippets and additional explanation (Sam - MSFT in Visual Basic .NET asked for)
So about code, I try to explain in detail here.
First Class:
Public Class Brett3
Public Sub New(ByVal Laenge As Integer)
Me.Laenge = Laenge ' Me. ist wichtig und richtig !!
End Sub
Private m_laenge As Integer
Public Property Laenge() As Integer
Get
Return m_laenge
End Get
Set(ByVal value As Integer)
m_laenge = value
End Set
End Property
End Class
in MAIN.vb
Private Dim Reihe3 As New List(Of Brett3)
.
Reihe3.Add(New Brett3(nr))
.
This works fine with retrieving
dim Brettget as Brett3
Brettget = Reihe(i)
i = Brettget.Laenge
Now I would like to gather this collection Reihe3 as a list of objects too.
I tried:
Public Class ReiheofBrett
Public Sub New(ByVal Reihe As List(Of Brett3) )
Me.Reihe = New List(Of Brett3)
End Sub
Private m_reihe As List(Of Brett3)
Public Property Reihe() As List(Of Brett3)
Get
Return m_reihe
End Get
Set(ByVal value As List(Of Brett3) )
m_reihe = value
End Set
End Property
End Class
now in Main.vb:
Dim Reihex As ReiheofBrett
Reihex = New ReiheofBrett(Reihe3)
this Reihex = will occur several times, each time the collection "reihe3" contains a differnt number of entries
Compiler accepts, program works
so, Reihex should contain the collection "Reihe3" ?? or, what is wrong?
and doing it several times, there should exist several different objects of class ReiheofBrett ? (isn't)?
BUT, later, i am not able to retrieve the collection to a variable like Reihe3 again
I tried:
Dim Reiheget As ReiheofBrett
For each ReiheofBrett In Reiheget (or for each Reihe in Reiheget)
or for i = 0 to n
Reiheget = ReiheofBrett(i)
Question now:
Is it possible, to gather these objets "Reihe3" in ReiheofBrett (seems so)
But: How do I get back these objects out of ReiheofBrett
Thanks for your answer, but to gather the list of objects was o.k (see Reihe3 obove)
May be, it helps, if I shortly describe, what i am doing:
class Brett3 is a plank of laminate/parquet
first plank and last plank in a row (Reihe3) have different length
I compute the number of planks and different lenths and gather the collection. NOW, a row contains several planks.
for a room, i need a lot of rows.
Similar, as a row contains planks, the room contains rows, which I try to create as object, too
For sure, I could write my program without a class/object row (and i just did it). But I try to learn, how to di it consequently object oriented