Android Question Syntax error bug

techknight

Well-Known Member
Licensed User
Longtime User
I would like to be able to do this, but for some reason the compiler keeps throwing a syntax error:

B4X:
lblPlayer2.Text = "No player in Slot: " & PlayerIndex + 1

Probably because the +1 on the end.

See, I can do this in any other language except for this one for some reason unless I am doing it wrong? Maybe I need parenthesis? I am afraid if I put it in parenthesis that it would actually increment the variable by 1 instead of "referencing as it is plus 1"

The PlayerIndex is 0 based, and the label I want 1 based. So if PlayerIndex is 0, I want the user to see "1" hence why I put the + 1 on the end.

I really dont want to have to declare another variable and add another line of code if I dont have to.

any ideas?
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
lblPlayer2.Text = $"No player in Slot: ${PlayerIndex + 1}"$
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
That confused me mostly but I THINK I understand it.

So, Will this physically increment the variable? or it will it display a reference of the function as if the variable had 1 added to it? but the variable remain as is? Just curious.
 
Upvote 0
Top