Android Question Not all code paths return a value

ronell

Well-Known Member
Licensed User
Longtime User
i have warning in my code(see title)


Code: Copy
Sub activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then
        Private ans As Int
        ans = Msgbox2("Do you want to close the app?", "Close App","Yes","Logout","No", Null)
        If ans = DialogResponse.POSITIVE Then
            Activity.Finish
        Else If ans = DialogResponse.CANCEL  Then
            Activity.LoadLayout("frmlogin")
        Else
        
        End If
        Return True
      
    End If
End Sub

should i just ignore the warning ?
 
Hi,

Code: Copy
Sub activity_KeyPress (KeyCode As Int) As Boolean

If KeyCode = KeyCodes.KEYCODE_BACK Then
   
        Private ans As Int
        ans = Msgbox2("Do you want to close the app?", "Close App","Yes","Logout","No", Null)
           
        If ans = DialogResponse.POSITIVE Then
            Activity.Finish
        Else If ans = DialogResponse.CANCEL  Then
            Activity.LoadLayout("frmlogin")
        Else
   
        End If
   
        Return True
           
        Else 'Add this.
       
          Return False 'Add this.
 
    End If

End Sub

I have not tested your code.
 
Last edited:
Upvote 0
Back
Top