Android Question label text isn't working

anaylor01

Well-Known Member
Licensed User
Longtime User
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")
 

LucaMs

Expert
Licensed User
Longtime User
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

mc73

Well-Known Member
Licensed User
Longtime User
Just a guess, you redimmed or reinitialized lblHighScore somewhere, though it belongs to a layout?
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
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

DonManfred

Expert
Licensed User
Longtime User
And the code for the label is with the other code on that layout and they work.
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

Well-Known Member
Licensed User
Longtime User
What do you mean DonManfred? This is a label "
lblHighScore.Text = SQL1.ExecQuerySingleResult("SELECT max(teamscore) FROM GamePlay Limit 1""
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Here it is. I deleted it and added a new one and still doesn't work.
B4X:
Private lblhighscore1 As Label
 
Upvote 0

Lahksman

Active Member
Licensed User
Longtime User
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
Top