Android Question App crashes when trying to change a label's text

kostakost

Member
Hello!
I'm new to this forum (and generally in B4A and Android programming) and this is my first post.
I have a problem with the app I'm developing.
This is the code causing the crash, but I don't know how to fix it:
B4X:
Private DriveStartHour As Int = -1
Private DriveStartMin As Int = -1

Label1.Text = 4 - (DateTime.GetHour(DateTime.Now) - DriveStartHour) + "h  " + 30 - (DateTime.GetMinute(DateTime.Now) - DriveStartMin) + "  min remaining"

Could you please help me solve this problem?
Thank you
 

klaus

Expert
Licensed User
Longtime User
Try this:
Label1.Text = (4 - (DateTime.GetHour(DateTime.Now) - DriveStartHour)) & "h " & (30 - (DateTime.GetMinute(DateTime.Now) - DriveStartMin)) & " min remaining"
Calculations must be between brackets and the + sign musi be replaced by &.:
 
Upvote 0

kostakost

Member
Hello!
Thanks for replying! Sorry for not posting an error message, but I could not find it.
The code you wrote above works! :)
Thank you!
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
In Logs Tab at the right of the IDE you will see the errors.

upload_2018-8-6_13-31-22.png
 
Upvote 0
Top