Android Question Type with objects

Discussion in 'Android Questions' started by gruizelgruis, Jun 19, 2015.

  1. gruizelgruis

    gruizelgruis Member Licensed User

    Hi all,

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

    Code:
    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
    Code:
    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
     
  2. LucaMs

    LucaMs Expert Licensed User

    Code:
    Dim SalesList As List
    SalesList.Initialize

    For i = 0 To 10
         
    Dim Cur_prod As ProductsInfo
         Cur_prod.Initialize
         Cur_prod.id = i
         SalesList.add(Cur_prod)
    Next
     
  3. gruizelgruis

    gruizelgruis Member Licensed User

    @LucaMs I'm sorry I forgot to mention the ".initialize"
    I do use initialize in my code. Just forgot to put it up in here.
     
  4. LucaMs

    LucaMs Expert Licensed User

    Cur_prod.Initialize solves the problem.
     
  5. gruizelgruis

    gruizelgruis Member Licensed 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.
     
    RandomCoder likes this.
Loading...