Cronometer Crfeation


#1

hi there,

I need to construct a cronometer to control a quiz time execution, how do I calculate the time and show it as HH:MM:SS ?

Thanks in advance.


#2

Does this help?

http://wiki.nsbasic.com/Conversions


#3

Yes, just one thing, I need to show this as 99:99hrs.

Thank you!


#4

Example:

I start a Quiz, while the quiz is running I want to show how much time is running since the start, to for example , controle the quiz time, in secoinds, butr I need to how it in 99:00hrs format !

Thank you in advance !


#5

Why not format the value into a string and display it in a Label?


#6

Ok, but the result is a number of seconds, there is a conversion function
to this ?

I just don´t know how to calculate the difference between time star and
time end !

Thank you !

RICARDO CASSOLATTO

Business Consultant
sintetik@gmail.com / 21 98196-0504

FastMobile
http://fastmobile.info
http://www.facebook.com/ricardo.cassolatto
https://br.linkedin.com/in/ricardo-cassolato-9ba225


#7

I found a good javascript example, it´s ok for a while:

var timercount = 0;
var timestart = null;

function showtimer() {
if(timercount) {
clearTimeout(timercount);
clockID = 0;
}
if(!timestart){
timestart = new Date();
}
var timeend = new Date();
var timedifference = timeend.getTime() - timestart.getTime();
timeend.setTime(timedifference);
var minutes_passed = timeend.getMinutes();
if(minutes_passed < 10){
minutes_passed = “0” + minutes_passed;
}
var seconds_passed = timeend.getSeconds();
if(seconds_passed < 10){
seconds_passed = “0” + seconds_passed;
}
document.timeform.timetextarea.value = minutes_passed + “:” + seconds_passed
;
timercount = setTimeout(“showtimer()”, 1000);
}

function sw_start(){
if(!timercount){
timestart = new Date();
document.timeform.timetextarea.value = “00:00”;
document.timeform.laptime.value = “”;
timercount = setTimeout(“showtimer()”, 1000);
}
else{
var timeend = new Date();
var timedifference = timeend.getTime() - timestart.getTime();
timeend.setTime(timedifference);
var minutes_passed = timeend.getMinutes();
if(minutes_passed < 10){
minutes_passed = “0” + minutes_passed;
}
var seconds_passed = timeend.getSeconds();
if(seconds_passed < 10){
seconds_passed = “0” + seconds_passed;
}
var milliseconds_passed = timeend.getMilliseconds();
if(milliseconds_passed < 10){
milliseconds_passed = “00” + milliseconds_passed;
}
else if(milliseconds_passed < 100){
milliseconds_passed = “0” + milliseconds_passed;
}
document.timeform.laptime.value = minutes_passed + “:” + seconds_passed +
"." + milliseconds_passed;
}
}

function Stop() {
if(timercount) {
clearTimeout(timercount);
timercount = 0;
var timeend = new Date();
var timedifference = timeend.getTime() - timestart.getTime();
timeend.setTime(timedifference);
var minutes_passed = timeend.getMinutes();
if(minutes_passed < 10){
minutes_passed = “0” + minutes_passed;
}
var seconds_passed = timeend.getSeconds();
if(seconds_passed < 10){
seconds_passed = “0” + seconds_passed;
}
var milliseconds_passed = timeend.getMilliseconds();
if(milliseconds_passed < 10){
milliseconds_passed = “00” + milliseconds_passed;
}
else if(milliseconds_passed < 100){
milliseconds_passed = “0” + milliseconds_passed;
}
document.timeform.timetextarea.value = minutes_passed + “:” + seconds_passed

  • “.” + milliseconds_passed;
    }
    timestart = null;
    }

function Reset() {
timestart = null;
document.timeform.timetextarea.value = “00:00”;
document.timeform.laptime.value = “”;
}

Thank you !

RICARDO CASSOLATTO

Business Consultant
sintetik@gmail.com / 21 98196-0504

FastMobile
http://fastmobile.info
http://www.facebook.com/ricardo.cassolatto
https://br.linkedin.com/in/ricardo-cassolato-9ba225


#8

I´ve done this code:

nSegundos and nMinutos are global vars

Function frmQuiz_onshow()
debugger
nTimer = SetInterval( Crono , 1000 )
End Function
’============ função de timer ======================
Function Crono()
debugger
nSegundos++
If nSegundos > 60 Then
nSegundos = 0
nMinutos++
End If
If nMinutos > 60 Then
nMinutos = 0
End If
cMinuto = ""
If nMinutos <10 Then
cMinuto = "0"
End If
cMinuto = cMinuto + Trim( CStr( nMinutos ) )

cSegundo = "“
If nSegundos<10 Then
cSegundo = “0"
End If
cSegundo = cSegundo + Trim( CStr( nSegundos ) )
lblRelogio.value = cMinuto+”:”+cSegundo
End Function

For the first time it executes Crono, ok, but when debugging, it simply show undefined, in the console nothing happens, and it just stop to work, and nothing in the console or debugger in chrome !

Thansk in advance !


#9

it´s showing me this all the time:


#10

Then, this label is a BootStrap Label


#11

somebody can help me please ?

thanks !