"If" not firing, what am i missing?

MichaelTJ

Member
Licensed User
Longtime User
for i = 0 to 8
If "Label" & (((i * 2) + i) + 2) & ".Text" = "M" Then


according to the "Global variables" panel bottom center, the value of Label2.text and Label5.text are both equal to "M" however, the above "If" does not fire

i assume i am staring right past something obvious
 

MichaelTJ

Member
Licensed User
Longtime User
using "AND" in place of "&" causes "Cannot parse: Label as bollean"
i so wish the "If" statement to evaluate the "Label2.Text" and "Label5.text" labels
 
Upvote 0

MichaelTJ

Member
Licensed User
Longtime User
perhaps not possible?

i thought i had done something like this previously but upon checking discovered that i had not..... perhaps cone cannot assemble the label"Label5.text" so that it can be evaluated as i have attempted to do.... i'd love to be contradicted on this
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You can't access a view name through a string like that, you'll need to store the Label references in an array of Labels

B4X:
Dim LabelArr() As Label

You can add them when creating them in code, or if created in the designer, like this:

B4X:
LabelArr=Array As Label(Label0,Label1,Label2,Label3)

then you can do:

B4X:
If LabelArr(((i * 2) + i) + 2).Text = "M" Then
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
A Map, very clever. That's another good thing about b4a, never say never! :) you get lots of choices.

-------------------
Sent via Tapatalk
 
Upvote 0
Top