Hi all,
Again a beginner's question.
I want to create an array of Label but the number of Label is only known after a certain point in Sub Activity_Create.
If the number of label is known in advance (in this case 6) then this code below works:
How to do this when the number of labels (Lbl1 .. Lbl6) is not known before hand but only after a certain point in Sub Activity_Create? In other words, is it possible to do
and
in an iterative manner after the number of Label is known?
Thanks!
Again a beginner's question.
I want to create an array of Label but the number of Label is only known after a certain point in Sub Activity_Create.
If the number of label is known in advance (in this case 6) then this code below works:
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim lblWoord() As Label
Dim Lbl1, Lbl2, Lbl3, Lbl4, Lbl5, Lbl6 As Label
End Sub
Sub Activity_Create
...
lblWoord = Array As Label(Lbl1, Lbl2, Lbl3, Lbl4, Lbl5, Lbl6)
...
For i = 0 To 5
lblWoord(i).Initialize("lblWoord")
lblWoord(i).TextColor = Colors.black
lblWoord(i).TextSize = 16
...
...
Next
End Sub
How to do this when the number of labels (Lbl1 .. Lbl6) is not known before hand but only after a certain point in Sub Activity_Create? In other words, is it possible to do
B4X:
Dim Lbl1, Lbl2, Lbl3, Lbl4, Lbl5, Lbl6 As Label
B4X:
lblWoord = Array As Label(Lbl1, Lbl2, Lbl3, Lbl4, Lbl5, Lbl6)
in an iterative manner after the number of Label is known?
Thanks!
Last edited: