segundos en cuenta regresiva a minutos
hola amigos
el ejemplo esta mas abajo... por favor en que estoy chocando
tengo un Label en el que recibo una cuenta regresiva en segundos
Ejemplo: 180 segundos que equivalen a 3 minutos
es posible transformar el valor del label en formato 00:03:00
En un modulo tengo esto:
Public Function HorasMinutosSegundos(lSegundos As Long) As String
en el label llamado lbl_hms tengo esto:
On Error GoTo ErrorHandler
Frmclave_ini.lbl_hms.Caption = HorasMinutosSegundos
Format$(CInt(CInt(lSegundos / 60) / 60), "00") & ":" & _
Format$(CStr(Int(lSegundos / 60) Mod 60), "00") & ":" & _
Format$(CStr(lSegundos Mod 60), "00")
On Error GoTo 0
Exit Function
ErrorHandler:
HorasMinutosSegundos = "00:00:00"
On Error GoTo 0
End Function
Pleace help¡
el ejemplo esta mas abajo... por favor en que estoy chocando
tengo un Label en el que recibo una cuenta regresiva en segundos
Ejemplo: 180 segundos que equivalen a 3 minutos
es posible transformar el valor del label en formato 00:03:00
En un modulo tengo esto:
Public Function HorasMinutosSegundos(lSegundos As Long) As String
en el label llamado lbl_hms tengo esto:
On Error GoTo ErrorHandler
Frmclave_ini.lbl_hms.Caption = HorasMinutosSegundos
Format$(CInt(CInt(lSegundos / 60) / 60), "00") & ":" & _
Format$(CStr(Int(lSegundos / 60) Mod 60), "00") & ":" & _
Format$(CStr(lSegundos Mod 60), "00")
On Error GoTo 0
Exit Function
ErrorHandler:
HorasMinutosSegundos = "00:00:00"
On Error GoTo 0
End Function
Pleace help¡
Te pongo un código sin probar ha ver si te funciona.
Public Function HorasMinutosSegundos(lSegundos As Long) As String
Dim h as Integer, m as Integer, s as Integer
h = lSegundos 3600
m = (lSegundos Mod 3600) 60
s = lSegundos Mod 60
HorasMinutosSegundos = Format$(h,"00") & ":" & Format$(m,"00") & ":" & Format$(s,"00")
End Function
P.D.: si divides con en lugar de / sólo devuelve la parte entera y no necesitas CInt().
Public Function HorasMinutosSegundos(lSegundos As Long) As String
Dim h as Integer, m as Integer, s as Integer
h = lSegundos 3600
m = (lSegundos Mod 3600) 60
s = lSegundos Mod 60
HorasMinutosSegundos = Format$(h,"00") & ":" & Format$(m,"00") & ":" & Format$(s,"00")
End Function
P.D.: si divides con en lugar de / sólo devuelve la parte entera y no necesitas CInt().
