Is there a more efficient way to check a lot of tags?

PharCyDeD

Active Member
Licensed User
Longtime User
I have the code:

B4X:
If Spot1.Tag = Spot2.Tag Then

Match = Match + 1

End If

I need to check a lot of tags like: Spot1.Tag = Spot3.Tag, etc. I know I can run it with a bunch of If Then's but is there a better way to do this? I am just trying to learn how to be more efficient with less lines of code.
 

PharCyDeD

Active Member
Licensed User
Longtime User
Well I need to compare Spot1.tag to against 35 other tags like this:

B4X:
If Spot1.Tag = Spot1Match.Tag Then

Match = Match + 1

End If

If Spot1.Tag = Spot2.Tag Then

Match = Match + 1

End If

If Spot1.Tag = Spot2Match.Tag Then

Match = Match + 1

End If

If Spot1.Tag = Spot3.Tag Then

Match = Match + 1

End If

If Spot1.Tag = Spot3Match.Tag Then

Match = Match + 1

End If

That goes all the way up to Spot18Match make it compared against 35 total tags. Then I need to do the same with each other tag as well like:

B4X:
If Spot1Match.Tag = Spot1.Tag Then

Match = Match + 1

End If

If Spot1Match.Tag = Spot2.Tag Then

Match = Match + 1

End If

If Spot1Match.Tag = Spot2Match.Tag Then

Match = Match + 1

End If

Each ImageView tag needs to be compared because it is setting a "game over" variable for the game.
 
Upvote 0

PharCyDeD

Active Member
Licensed User
Longtime User
I tried this but it doesn't work :(

B4X:
SpotCount = 0
   Number = 0
   Do While SpotCount < 18
   
      SpotCount = SpotCount + 1
      Number = Number + 1
      If Spot1.Tag = "Spot" & Number & ".Tag" Then
   
         GameOver = GameOver + 1
      
      End If
      
   Loop
   
   SpotCount = 0
   Number = 0
   Do While SpotCount < 18
   
      SpotCount = SpotCount + 1
      Number = Number + 1
      If Spot1.Tag = "Spot" & Number & "Match.Tag" Then
   
         GameOver = GameOver + 1
      
      End If
      
   Loop
 
Upvote 0
Top