Android Question new class istance

Loris Anoardi

Member
Licensed User
Longtime User
How can i create a new istance of a class ? the corresponding set x = new clsTest of Vb ?
The initialize method doesn't do that...
 

Loris Anoardi

Member
Licensed User
Longtime User
Erel i use initialize but it doesn't create a new istance
<code>
Dim A As Articolo
For I = 0 To lstArticoli.Size - 1
M = lstArticoli.Get(I)
A.Initialize(func.CInt(m.Get("codice")),m.Get("descrizione"),func.CDbl(m.Get("prezzo")),m.Get("reparto"),Null, Null, Null, Null, Null, Null)
J = J + 1
Dim B As Button
B.Initialize("BottoneArticolo")
B.Text = M.Get("descrizione")
B.Tag = A
next
</code>
-A- is the class
In the click event of BottoneArticolo the value of the tag is only the same istance of A.
 
Upvote 0

Ed Brown

Active Member
Licensed User
Longtime User
Erel i use initialize but it doesn't create a new istance
<code>
Dim A As Articolo
For I = 0 To lstArticoli.Size - 1
M = lstArticoli.Get(I)
A.Initialize(func.CInt(m.Get("codice")),m.Get("descrizione"),func.CDbl(m.Get("prezzo")),m.Get("reparto"),Null, Null, Null, Null, Null, Null)
J = J + 1
Dim B As Button
B.Initialize("BottoneArticolo")
B.Text = M.Get("descrizione")
B.Tag = A
next
</code>
-A- is the class
In the click event of BottoneArticolo the value of the tag is only the same istance of A.
Hello @Loris Anoardi

You are almost there. You need to move the "DIM A As Articolo" statement inside the FOR/NEXT loop just before you initialise it and that will create a new instance of the class for each button.
 
Last edited:
Upvote 0
Top