Visual Basic - como resto horas

Life is soft - evento anual de software empresarial
 
Vista:

como resto horas

Publicado por guillermo (1 intervención) el 05/09/2005 19:31:53
Hola necesito calcular las horas trabajadas a partir de dos maskedbox que tiene una fecha inicial y otro la fecha final
maskedbox1.text = 17:30 PM
maskedbox2.text = 18:40 PM

resultado 1:10:00 (una hora con 10 minutos), he podido calcular una fecha pero la hora no me resulta., alguien tiene una idea de como hacerlo

gracias GUILLE
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:como resto horas

Publicado por miguel (1042 intervenciones) el 05/09/2005 20:52:21
Ejemplo:
Private Sub Command1_Click()
Dim vlvalor As String
vlvalor = DateDiffEx(Me.mskHoraIncio.Text, Me.mskHoraFinal.Text)
MsgBox vlvalor
End Sub
Public Function DateDiffEx(StartTime, EndTime) As String

DateDiffEx = DateDiffExFormat(DateDiff("d", StartTime, EndTime) \ 365, "Año")
DateDiffEx = DateDiffEx & DateDiffExFormat((DateDiff("s", StartTime, EndTime) \ 86400) _
Mod 365, "día")
DateDiffEx = DateDiffEx & DateDiffExFormat((DateDiff("s", StartTime, EndTime) \ 3600) _
Mod 24, "hora")
DateDiffEx = DateDiffEx & DateDiffExFormat((DateDiff("s", StartTime, EndTime) \ 60) _
Mod 60, "minuto")
DateDiffEx = DateDiffEx & DateDiffExFormat(DateDiff("s", StartTime, EndTime) _
Mod 60, "segundos")

If Len(DateDiffEx) > 0 Then
DateDiffEx = Mid(DateDiffEx, 1, Len(DateDiffEx) - 2)
End If

End Function

Private Function DateDiffExFormat(inputValue As Long, unitValue As String) As String

If inputValue <> 0 Then
DateDiffExFormat = inputValue & " " & unitValue & IIf(inputValue <> 1, "s", "") & ", "
End If

End Function

Si no puedes hacerlo que funcione te puedo mandar un ejemplo a tu correo...saludos!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:como resto horas

Publicado por EGV (385 intervenciones) el 06/09/2005 15:11:34
tenes un codigo que coloque en la web Diferencia Horaria, miralo y a lo mejor te sirve o bien adaptalo a lo que necesitas
suerte
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar