Android Question [SOLVED] Insert type into list

makis_best

Well-Known Member
Licensed User
Longtime User
Hi

I am confused about how to insert a type into a list

So far I have....

B4X:
Sub Process_Globals
    Thelist As List
    TheList.initialize
    Type TheRT(Code As String, Description As String, Price As Double, Quantity As Double)
    Public ItemInfo As TheRT
End Sub

Sub ItemTable_All_Items_CellClick(col As Int, row As Int)
            ItemInfo.initialize
            ItemInfo.Code = ItemTable_All_Items.GetValue(0,row)         
            ItemInfo.Description = ItemTable_All_Items.GetValue(1,row)
            ItemInfo.Munit = ItemTable_All_Items.GetValue(2,row)        
            ItemInfo.Price = NumberFormat2(Price1, 1, 0, 4, False)        
            ItemInfo.Quantity = NumberFormat2(Quantity1, 1, 0, 2, False)
            Thelist.Add(PublicCode.ItemInfo)
End Sub

What I miss?
What I do wrong?
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
What I miss?
dimming the type inside the sub
B4X:
Sub ItemTable_All_Items_CellClick(col As Int, row As Int)
dim ItemInfo As TheRT
ItemInfo.initialize
            ItemInfo.Code = ItemTable_All_Items.GetValue(0,row)        
            ItemInfo.Description = ItemTable_All_Items.GetValue(1,row)
            ItemInfo.Munit = ItemTable_All_Items.GetValue(2,row)       
            ItemInfo.Price = NumberFormat2(Price1, 1, 0, 4, False)       
            ItemInfo.Quantity = NumberFormat2(Quantity1, 1, 0, 2, False)
            Thelist.Add(ItemInfo)
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
the type ist just a struct and also a class
B4X:
For Each entity as TheRT in Thelist
Log( entity.Price )


RegEx
https://www.b4x.com/android/forum/threads/b4x-regular-expressions-regex-tutorial.7123/

If the Dimming is made on another module doesn't work?

it must be declared public
you need to write the Modul name before + a dot.
have in mind that code moduls not have events.
better use a class.
as Manfred said do not reuse a struct. prevent using global variables.
it is also not good to write code direct inside a click event sub.
 
Last edited:
Upvote 0
Top