Android Question Type with objects

gruizelgruis

Member
Licensed User
Longtime User
Hi all,

I use a type to store info. and add that to a list

B4X:
Type ProductsInfo(Id As Long, Name As String, MyButton as object)
Dim SalesList As List

For i = 0 to 10
     Dim Cur_prod as ProductsInfo
     cur_prod.id = i
     saleslist.add(Cur_Prod)
next

Works fine

But when I change the Type declaration with "MyButton as button" like
B4X:
Type ProductsInfo(Id As Long, Name As String, MyButton as Button)
Dim SalesList As List

For i = 0 to 10
     Dim Cur_prod as ProductsInfo
     cur_prod.id = i
     saleslist.add(Cur_Prod)
next

I get an error/warning "Object expected" How Can I solve this?

Adding Cur_Prod.myButton = null does not work. please advice
 

gruizelgruis

Member
Licensed User
Longtime User
I did not mention that the code above is in a "codemodule"
One can't declare objects explicitly in a code module.
I moved the "type" and "list" declarations to an "activity module"
The problem is solved.
 
Upvote 0
Top