SoyEli Active Member Licensed User Longtime User May 13, 2013 #1 Hello: I'm getting this under: Sub Activity_KeyPress (KeyCode As Int) As Boolean not all code paths return a value (warning #2) Why? Thank you:
Hello: I'm getting this under: Sub Activity_KeyPress (KeyCode As Int) As Boolean not all code paths return a value (warning #2) Why? Thank you:
PenguinHero Member Licensed User Longtime User May 14, 2013 #2 Hi SoyEli, I presume that you have some code in that Sub. Is it possible that you have conditions (if statements) that would prevent a value being returned for the Sub, that you are only returning a value when a certain condition is met? You can paste the code and let everyone have a look. And its probably stating the obvious, but it is only a warning. If your code is doing what you want it to, its probably safe to ignore it. Upvote 0
Hi SoyEli, I presume that you have some code in that Sub. Is it possible that you have conditions (if statements) that would prevent a value being returned for the Sub, that you are only returning a value when a certain condition is met? You can paste the code and let everyone have a look. And its probably stating the obvious, but it is only a warning. If your code is doing what you want it to, its probably safe to ignore it.
Erel B4X founder Staff member Licensed User Longtime User May 14, 2013 #3 My guess is that you are not returning any value from this sub. This event expects a boolean result. True means that the keypress is consumed. Upvote 0
My guess is that you are not returning any value from this sub. This event expects a boolean result. True means that the keypress is consumed.
SoyEli Active Member Licensed User Longtime User May 14, 2013 #4 Thank you for any help; Here is the code: Is working ok, did not show any error on prev b4a., only on upgrade to 2.70 Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then If MapPanel.Visible=True Then Main.BringToFront MapPanel.SendToBack MapPanel.Visible=False MapPanel.RemoveAllViews Return True End If If Main.Visible=True Then HomeScreen Return True End If End If End Sub Upvote 0
Thank you for any help; Here is the code: Is working ok, did not show any error on prev b4a., only on upgrade to 2.70 Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then If MapPanel.Visible=True Then Main.BringToFront MapPanel.SendToBack MapPanel.Visible=False MapPanel.RemoveAllViews Return True End If If Main.Visible=True Then HomeScreen Return True End If End If End Sub
yttrium Active Member Licensed User Longtime User May 14, 2013 #5 Please use code tags next time. Your code should be the following, though I don't know if this is redundant: Code: Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then If MapPanel.Visible=True Then Main.BringToFront MapPanel.SendToBack MapPanel.Visible=False MapPanel.RemoveAllViews Return True End If If Main.Visible=True Then HomeScreen Return True End If End If Return False End Sub Last edited: May 14, 2013 Upvote 0
Please use code tags next time. Your code should be the following, though I don't know if this is redundant: Code: Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then If MapPanel.Visible=True Then Main.BringToFront MapPanel.SendToBack MapPanel.Visible=False MapPanel.RemoveAllViews Return True End If If Main.Visible=True Then HomeScreen Return True End If End If Return False End Sub
agraham Expert Licensed User Longtime User May 14, 2013 #6 You are missing a return value if the KeyCode is not KeyCodes.KEYCODE_BACK Code: Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then If MapPanel.Visible=True Then Main.BringToFront MapPanel.SendToBack MapPanel.Visible=False MapPanel.RemoveAllViews Return True End If If Main.Visible=True Then HomeScreen Return True End If End If Return False ' You are missing this return value if the IF block above is not entered End Sub Upvote 0
You are missing a return value if the KeyCode is not KeyCodes.KEYCODE_BACK Code: Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then If MapPanel.Visible=True Then Main.BringToFront MapPanel.SendToBack MapPanel.Visible=False MapPanel.RemoveAllViews Return True End If If Main.Visible=True Then HomeScreen Return True End If End If Return False ' You are missing this return value if the IF block above is not entered End Sub
SoyEli Active Member Licensed User Longtime User May 14, 2013 #7 Thank you !!! that worked. Please explain: "code tags" Upvote 0
yttrium Active Member Licensed User Longtime User May 14, 2013 #8 SoyEli said: Thank you !!! that worked. Please explain: "code tags" Click to expand... This forum has a special set of BBCode tags when posting that formats your text nicely. For example, HTML: [code]Dim Button1 As Button[/code] displays as Code: Dim Button1 As Button Upvote 0
SoyEli said: Thank you !!! that worked. Please explain: "code tags" Click to expand... This forum has a special set of BBCode tags when posting that formats your text nicely. For example, HTML: [code]Dim Button1 As Button[/code] displays as Code: Dim Button1 As Button