A anaylor01 Well-Known Member Licensed User Longtime User Apr 8, 2016 #1 I am confused as to why the below code doesn't work. The two message boxes work fine. The lblhighscore.text doesn't do anything. B4X: Msgbox(SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1"),"HighScore") lblHighScore.Text = SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1") Msgbox(SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1"),"HighScore")
I am confused as to why the below code doesn't work. The two message boxes work fine. The lblhighscore.text doesn't do anything. B4X: Msgbox(SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1"),"HighScore") lblHighScore.Text = SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1") Msgbox(SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1"),"HighScore")
Erel B4X founder Staff member Licensed User Longtime User Apr 8, 2016 #2 What is the output of Log (SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1") ? If you don't see it in the label then you didn't add the label correctly. Upvote 0
What is the output of Log (SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1") ? If you don't see it in the label then you didn't add the label correctly.
LucaMs Expert Licensed User Longtime User Apr 8, 2016 #3 This is one of many reasons to separate data (and their construction / retrieval) from GUI. If you had: Dim TeamHighScore As Int = modDB.GetTeamHighScore (SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1") in your modDB module) lblHighScore.Text = TeamHighScore you could debug your code, checking the TeamHighScore value Upvote 0
This is one of many reasons to separate data (and their construction / retrieval) from GUI. If you had: Dim TeamHighScore As Int = modDB.GetTeamHighScore (SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1") in your modDB module) lblHighScore.Text = TeamHighScore you could debug your code, checking the TeamHighScore value
mc73 Well-Known Member Licensed User Longtime User Apr 8, 2016 #4 Just a guess, you redimmed or reinitialized lblHighScore somewhere, though it belongs to a layout? Upvote 0
A anaylor01 Well-Known Member Licensed User Longtime User Apr 8, 2016 #5 Erel: The output of the log is 80 which is the highscore. mc73: I am pretty sure I did not. And the code for the label is with the other code on that layout and they work. Upvote 0
Erel: The output of the log is 80 which is the highscore. mc73: I am pretty sure I did not. And the code for the label is with the other code on that layout and they work.
DonManfred Expert Licensed User Longtime User Apr 8, 2016 #6 anaylor01 said: And the code for the label is with the other code on that layout and they work. Click to expand... There is no label in your code in post #1 Create a small project which shows the problem and upload it. I´m sure the problem is with your code somehow Upvote 0
anaylor01 said: And the code for the label is with the other code on that layout and they work. Click to expand... There is no label in your code in post #1 Create a small project which shows the problem and upload it. I´m sure the problem is with your code somehow
A anaylor01 Well-Known Member Licensed User Longtime User Apr 8, 2016 #7 What do you mean DonManfred? This is a label " lblHighScore.Text = SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1"" Upvote 0
What do you mean DonManfred? This is a label " lblHighScore.Text = SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1""
fixit30 Active Member Licensed User Longtime User Apr 8, 2016 #8 anaylor01 said: What do you mean DonManfred? This is a label " Click to expand... He means that we do not see in your code above B4X: Dim lblHighScore as Label Upvote 0
anaylor01 said: What do you mean DonManfred? This is a label " Click to expand... He means that we do not see in your code above B4X: Dim lblHighScore as Label
A anaylor01 Well-Known Member Licensed User Longtime User Apr 8, 2016 #9 Here it is. I deleted it and added a new one and still doesn't work. B4X: Private lblhighscore1 As Label Upvote 0
Here it is. I deleted it and added a new one and still doesn't work. B4X: Private lblhighscore1 As Label
Lahksman Active Member Licensed User Longtime User Apr 8, 2016 #10 If you add a label in code (and not through the designer) you should also initialize it. B4X: Dim lblHighScore as label lblHighScore.initialize("") Upvote 0
If you add a label in code (and not through the designer) you should also initialize it. B4X: Dim lblHighScore as label lblHighScore.initialize("")
A anaylor01 Well-Known Member Licensed User Longtime User Apr 8, 2016 #11 I moved it to another place and it works. So that is odd. Upvote 0