Hi All,
Probably a simple thing but it is screwing with my head.
At times in a project I have a number of labels [lblF0 -- lblF15] that need their text colour changed. The text on the label is assigned by the user so this cannot be used to identify the label.
I can do this by changing each label individually I am trying to do it within a loop but trying to identify the label by name triggers errors. I've tried several variations and usually get a Mixed Type error.
This works but is a bit like a sledge hammer.
This more like I am trying to do.
Thanks in advance for the simple answer that will be obvious once you tell me.
Regards Roger
Probably a simple thing but it is screwing with my head.
At times in a project I have a number of labels [lblF0 -- lblF15] that need their text colour changed. The text on the label is assigned by the user so this cannot be used to identify the label.
I can do this by changing each label individually I am trying to do it within a loop but trying to identify the label by name triggers errors. I've tried several variations and usually get a Mixed Type error.
This works but is a bit like a sledge hammer.
B4X:
' lblF0.TextColor = Colors.Gray
' lblF1.TextColor = Colors.Gray
' lblF2.TextColor = Colors.Gray
' lblF3.TextColor = Colors.Gray
' lblF4.TextColor = Colors.Gray
' lblF5.TextColor = Colors.Gray
' lblF6.TextColor = Colors.Gray
' lblF7.TextColor = Colors.Gray
' lblF8.TextColor = Colors.Gray
' lblF9.TextColor = Colors.Gray
' lblF10.TextColor = Colors.Gray
' lblF11.TextColor = Colors.Gray
' lblF12.TextColor = Colors.Gray
' lblF13.TextColor = Colors.Gray
' lblF14.TextColor = Colors.Gray
' lblF15.TextColor = Colors.Gray
This more like I am trying to do.
B4X:
For Each v As View In Activity.GetAllViewsRecursive
If v Is Label Then
Private LblFF As Label = v
For W = 0 To 15
If v = "lblF"&W Then 'It is here trying to Name the Label from the loop is where I fail.
LblFF.TextColor = Colors.Gray 'If I can get the principle correct the colour can be varied.
End If
Next
End If
Next
Thanks in advance for the simple answer that will be obvious once you tell me.
Regards Roger