Android Question Help: If wKey.Tag = ... is always FALSE

Discussion in 'Android Questions' started by FERNANDO SILVEIRA, Apr 7, 2018.

  1. FERNANDO SILVEIRA

    FERNANDO SILVEIRA Active Member Licensed User

    Hello, guys...

    I'm working on the following code and the IF clause (If wKey.Tag = wTunesApp(wIndex) Then) always returns false. The Tag field values are 0, 1, 2 and 3... and wTunesApp(wIndex) = rnd(0, 4).

    I know that rnd() returns an int and Tag is a string... That could explain the false result on the IF, then I tried to use NumberFormat2(Rnd(0, 4),1,0,0,False) to convert to string, but still the IF clause returns false.

    Don't know what to do.
    Attached you may find the whole project.

    Regards,
    Fernando

    Code:
    Sub lblButton_Click
        wKey = 
    Sender
        
    Log("lblButton_Click: Tecla User " & wKey.tag)
        wKey.Color = wTabColorON(wKey.Tag)        
    ' Light Color
        PlayTune(wKey.Tag)
        wKey.Color = wTabColorOFF(wKey.Tag)        
    ' Dark Color
       
        
    If wKey.Tag = wTunesApp(wIndex) Then
            
    Log("Clicou Certo")
            GetNewKey
            APPplayTunes
        
    Else 
            
    Log("lblButton_Click: " & wIndex & ") Clicou Errado: " & wKey.Tag & " deveria ser " & wTunesApp(wIndex))
            wCtError = wCtError + 
    1
            
    If wCtError > 3 Then
                
    Msgbox("You missed 3 tunes""Game Over")
                GameOver
            
    Else
                
    Msgbox("Wrong Key sequence""Try Again")
                APPplayTunes
            
    End If
        
    End If
    End Sub
     

    Attached Files:

  2. klaus

    klaus Expert Licensed User

    Use this code:
    Code:
    Private wTag As Int
    wTag = wKey.Tag
    If wTag = wTunesApp(wIndex) Then
    No, the Tag property holds an object!
     
    PassionDEV and FERNANDO SILVEIRA like this.
  3. FERNANDO SILVEIRA

    FERNANDO SILVEIRA Active Member Licensed User

    Got it.
    Thanx.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice