Adding Tag data to Label error

enonod

Well-Known Member
Licensed User
Longtime User
I am trying to store the position of a label within a row/column
I have the following in principle...
B4X:
Type Harry(col As Byte, row As Byte)
Dim pos as Harry
Dim Tom as Label
...
pos.col=x : pos.row=y
...
Tom(pos, "abc")
...

Sub Tom(loc as Harry, sEvent as String)
   Dim Dick As Label
   Dim Dick.Tag As Harry ''Error unknown type Tag. Missing library?
   Dick.Initialize(sEvent)
   brk.Tag=loc
Tag works if I use a simple array instead of type.
All items used appear in the dropdown lists i.e. when typing Dim brk.Tag As Harry, Tag and Harry were offered.
What is wrong please?
 
Last edited:

enonod

Well-Known Member
Licensed User
Longtime User
Thanks JonPM, that works fine.
It seems from what you say that the problem is that the Tag does not need to be Dim'd first, just stick anything in.
 
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
Not quite true. It works but cannot be retrieved correctly. I still need help.
The code is now...
B4X:
Type Harry(col As Byte, row As Byte)
Dim pos as Harry
Dim Tom, snd as Label
...
pos.col = x : pos.row = y
...
Tom(pos, "abc")
...

Sub Tom(loc as Harry, sEvent as String)
    Dim Dick As Label
    Dick.Initialize(sEvent)
    Dick.Tag = loc         '[I]save label's position as col and row[/I]
    pnl.AddView(Dick, ... ...)
End Sub

Sub abc_Click
    snd = Sender
    pos = snd.Tag   '[I]Retrieve the label's position as col and row[/I]
    ...
End Sub
I can see the col and row in Dick.Tag after it is stored. But when retrieved from Sender the row col are shown as incorrect last used values. Is there something about Tag that does not permit Type or is Sender the problem or am I the problem? No error is shown.
 
Last edited:
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
Yes, pretty stupid really.
Thank you Erel.
 
Upvote 0
Top