Como desglosar turno en horas diurnas y horas nocturnas
Publicado por juan francisco (5 intervenciones) el 09/01/2020 16:51:17
Necesito ayuda quiero un algoritmo o función que devuelva o desglose las horas diurnas y las horas nocturnas el horario nocturno es de 22:00 a 6:00, tengo el siguiente código vb6 lo quiero pasar a vb.net pero no se como mejorar este código o si hay alguna forma de optimizarlo y simplificarlo, gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Dim he, hs As Variant
he = Format(Text1, "hh:mm")
hs = Format(Text2, "hh:mm")
If TimeValue(he) < TimeValue(hs) And TimeValue(he) < #10:00:00 PM# And TimeValue(hs) <= #10:00:00 PM# Then
hd = TimeValue(he) - TimeValue(hs)
hn = "00:00"
Debug.Print "menor"
ElseIf TimeValue(he) < #10:00:00 PM# And TimeValue(hs) > #10:00:00 PM# And TimeValue(hs) <= #6:00:00 AM# Then
hd = TimeValue(he) - #10:00:00 PM#
hn = TimeValue(hs) + 1 - #10:00:00 PM#
Debug.Print hn
If hn > 0.333333333333334 Then
MsgBox "Revise el turno, las horas nocturnas no puede sobrepasar las 8 horas"
Text2.SetFocus
End If
Else
hd = #10:00:00 PM# - TimeValue(he)
hn = TimeValue(hs) + 1 - #10:00:00 PM#
Debug.Print hn
If hn > 0.333333333333334 Then
MsgBox "Revise el turno, las horas nocturnas no puede sobrepasar las 8 horas"
Text2.SetFocus
End If
End If
Label3 = Format(hd, "hh:mm")
Label4 = Format(hn, "hh:mm")
Label8 = Format(hds, "hh:mm")
Valora esta pregunta
0