Lo del tiempo transcurrido lo tengo manejado ya, pero para mostrar el tiempo restante me estoy haciendo un lío...
Dim time_out as integer = 60000 ' 'Milisegundos
Dim StartTime As DateTime ' Tiempo inicio
Dim EndTime As DateTime ' Tiempo final
Dim ElapsedTime As TimeSpan ' Tiempo transcurrido
Dim RemainingTime As TimeSpan ' Tiempo restante
He conseguido mostrar el tiempo restante pero de una manera extraña, el problema es que, aparte de que los valores se muestran negativos, el valor de la hora y el minutero deberían ser "00"... ya que sólo estoy intentando medir el tiempo restante de una operación de "10000" MS (10 segs)
Output:
(http://img41.imageshack.us/img41/9628/prtscrcapture3k.jpg)
Este es el code que uso, ¿Como lo arreglo?
#Region " Elapsed Time Function "
Public Function Print_Elapsed_Time()
If StartTime.ToString = "01/01/0001 0:00:00" Then
StartTime = Now
StartTime = StartTime.AddSeconds(-1)
End If
ElapsedTime = Now().Subtract(StartTime)
Return String.Format("{0:00}:{1:00}:{2:00}", CInt(Math.Floor(ElapsedTime.TotalHours)) Mod 60, CInt(Math.Floor(ElapsedTime.TotalMinutes)) Mod 60, CInt(Math.Floor(ElapsedTime.TotalSeconds)) Mod 60)
End Function
#End Region
#Region " Remaining Time Function "
Public Function Print_Remaining_Time()
If EndTime.ToString = "01/01/0001 0:00:00" Then
EndTime = Now
EndTime = EndTime.AddMilliseconds(Time_Out - 1000)
End If
RemainingTime = Now().Subtract(EndTime)
Return String.Format("{0:00}:{1:00}:{2:00}", CInt(Math.Floor(RemainingTime.TotalHours)) Mod 60, CInt(Math.Floor(RemainingTime.TotalMinutes)) Mod 60, CInt(Math.Floor(RemainingTime.TotalSeconds)) Mod 60)
End Function
#End Region
Ya está solucionado...
Cambiar:
RemainingTime = Now().Subtract(EndTime)
Por:
RemainingTime = EndTime.Subtract(Now)
Saludos.
Yo hice un código muy largo para poder hacer esto tan simple jaja que al final era algo tonto. Jeje.
Saludos.