Visual Basic - Para Silvia que solicitó intervalo(19/02/01 17:04)

Life is soft - evento anual de software empresarial
 
Vista:

Para Silvia que solicitó intervalo(19/02/01 17:04)

Publicado por José Luis (54 intervenciones) el 23/02/2001 06:54:58
tomando de lunes a viernes y de 9 a 19 horas

ejemplo :

depende el sistema de fecha que use tu güindous

format aaaa-mm-dd
fechai 2001-01-01 12:00
fechaf 2001-02-01 12:00 resultado 1 dias 0 horas
fechaf 2001-02-01 13:00 resultado 1 dias 1 horas
fechaf 2001-02-01 11:00 resultado 0 dias 9 horas

Debes colocar en un form

TEXT1 FECHA Y HORA DE INICIO
TEXT2 FECHA Y HORA DE RECEPCION
TEXT3 RESULTADO VALOR DIAS
TEXT4 RESULTADO VALOR HORAS
COMMAND1 PARA EJECUTAR

Private Sub Command1_Click()
If Not IsDate(Text1) Then
Text1 = "Err"
Exit Sub
End If
If Not IsDate(Text2) Then
Text2 = "Err"
Exit Sub
End If
If Text2 < Text1 Then
Text3 = "Err diferencia"
Exit Sub
End If
If Weekday(Text1) = 1 Or Weekday(Text1) = 7 Then
Text1 = "error dia semana"
Exit Sub
End If
If Weekday(Text2) = 1 Or Weekday(Text2) = 7 Then
Text2 = "error dia semana"
Exit Sub
End If
If Hour(Text1) < 9 Or Hour(Text1) > 19 Then
Text1 = "error hora"
Exit Sub
End If
If Hour(Text2) < 9 Or Hour(Text2) > 19 Then
Text2 = "error hora"
Exit Sub
End If
Text3 = ((DateDiff("d", Text1, Text2) \ 7) * 5) + (DateDiff("d", Text1, Text2) Mod 7)
If Hour(Text1) > Hour(Text2) Then
Text3 = Text3 - 1
Text4 = 19 - Hour(Text1)
Text4 = Text4 + (Hour(Text2) - 9)
ElseIf Hour(Text1) = Hour(Text2) Then
Text4 = 0
Else
Text4 = Hour(Text2) - Hour(Text1)
End If
End Sub

Saludos
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:Para Silvia que solicitó intervalo(19/02/01 17:

Publicado por Silvia (23 intervenciones) el 05/03/2001 13:06:34
Muchisimas gracias
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