M mackrackit Member Licensed User Longtime User May 28, 2019 #1 Hi, I have a button click that runs a SUB to create multiple labels. I can give each label a different text value, but I want each label to have a different name with the hopes of writing the data to a file at some point. This is a snippet of what I have been trying. Code: Copy SherdNum = SherdNum + 1 Dim xyz As String xyz = "lbl_Sherd_" & SherdNum Dim xyz As Label
Hi, I have a button click that runs a SUB to create multiple labels. I can give each label a different text value, but I want each label to have a different name with the hopes of writing the data to a file at some point. This is a snippet of what I have been trying. Code: Copy SherdNum = SherdNum + 1 Dim xyz As String xyz = "lbl_Sherd_" & SherdNum Dim xyz As Label
R ronell Well-Known Member Licensed User Longtime User May 28, 2019 #2 this tutorial will help you https://www.b4x.com/android/forum/threads/tick-tack-toe-working-with-arrays-of-views.8506/#post47508 one solution is to create the labels with different tags, not with different name, then you can retrieve the data separately Upvote 0
this tutorial will help you https://www.b4x.com/android/forum/threads/tick-tack-toe-working-with-arrays-of-views.8506/#post47508 one solution is to create the labels with different tags, not with different name, then you can retrieve the data separately
S sorex Expert Licensed User Longtime User May 28, 2019 #3 as ronell wrote you should store the naming into the view's tag. Code: Copy SherdNum = SherdNum + 1 Dim xyz As Label xyz.initialize("lbl") xyz.tag="lbl_Sherd_" & SherdNum xyz.text="text "& SherdNum then you can use the tag for identification Code: Copy sub lbl_Click dim l as label=sender log(l.tag & tab & l.text) end sub Upvote 0
as ronell wrote you should store the naming into the view's tag. Code: Copy SherdNum = SherdNum + 1 Dim xyz As Label xyz.initialize("lbl") xyz.tag="lbl_Sherd_" & SherdNum xyz.text="text "& SherdNum then you can use the tag for identification Code: Copy sub lbl_Click dim l as label=sender log(l.tag & tab & l.text) end sub
M mackrackit Member Licensed User Longtime User May 28, 2019 #4 Thanks to both of you! Using the tag makes sense. I will give it a try. Upvote 0