Is iit possibile to add an hour to countdown Timer. Because I need to play the lecture and it takes around two hours and half.
--
sure, that's possible
--
first you should understand, how that example is working
and after that, it should be no problem for you to add a global variable intHoursLeft...
remember: and hour has 60 minutes...
see also these general tips
alternatively now you also can use the new clock methods
--
DurationToHours
DurationToMinutes
DurationToSeconds
the second screenshot looks better
--
after having calculated intHoursLeft, you have to calculate the remaining millis like this
intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc
If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
which means in your case post a screenshot of your relevant blocks...
You probably will get more feedback then...
To download the aia file, upload it to App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...
--
this was the correct calculation of the hours
--
after having calculated intHoursLeft, you have to calculate the remaining millis like this
intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc
I think, it's important to understand, what you are doing...
therefore let's take an example and let's calculate it manually
let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds
now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds
I have been trying to calculate this equations you had mentioned since yesterday. Now,I understand more than before, but please learn me more.
-- let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds
after calculation of the hours, where are the remaining milliseconds now in your blocks?
now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds
also use Do it to debug your blocks, see tip 4 here
Sorry, I can't find the remaining milliseconds in block. but what I know that it is 1842000
--
as already said
after having calculated intHoursLeft, you have to calculate the remaining millis like this
intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc
it is YOU who should check the calculation...
--
and the tool to use is as already said Do it, see tip 4 here
Top 5 Tips: How to learn App Inventor
why do you use the LeadingZeros procedure for the remaining milliseconds?
let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds
you still forgot to answer these questions
now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds
what about providing some answers now?
1842000 milliseconds
how many minutes do you get? how many seconds do you get?
protip: take a look at the original solution here https://puravidaapps.com/countdown.php
Yes, I have got it now. Thank you Taifun.
--
But the problem is that the timer doesn't start countdown until become less than one hour.
Yes, you are right.
Now is working.
Thank you so much Taifun for your learning me.
I want to know is there an example for count-up instead?
is there an example for count-up instead?I don't know
probably you can find an example after doing a search in the forum?
also what about just trying to build it yourself?
you learned how to count down... to count up should be similar...
Can you please give me a hint how to start and I will complete the calculation.
--
sorry, I do not have time currently, you might want to try something yourself or someone else might chime in
--
What is the difference between count-up and count-down? Just reverse the numbers and get the difference in time. You know already how to calculate that difference.
--
Thank you Ghica,
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds
I will be happy if you give me an example in reverse of this example for countdown timer :
let's assume, we have 9042000 millisecondsfirst we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds
--
this thread was about count down timer and has been answered
--
your thread about count up timer is here: Count-up Timer
댓글 없음:
댓글 쓰기