Visual Basic - PONER TEXTO EN UN LABEL

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil
Val: 1
Ha disminuido su posición en 24 puestos en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

PONER TEXTO EN UN LABEL

Publicado por mrjuan76 (3 intervenciones) el 11/08/2015 21:58:56
Hola tengo un form con un label y un button.

Lo que quiero es que si estamos entre las 06:00 y las 13:59 el label = "TURNO DE MAÑANA"
Si estamos entre las 14:00 y las 21:59 el label = "TURNO DE TARDE"
Si estamos entre las 22:00 y las 05:59 el label ponga "TURNO DE NOCHE"

El código que tengo es:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Private Sub Command1_Click()
 
HORAACT = Hour(Now)
 
Select Case HORAACT
 
Case Is > 6, Is <= 14
 
Label1.Caption = "TURNO DE MAÑANA"
 
Case Is > 14, Is <= 22
 
Label1.Caption = "TURNO DE TARDE"
 
Case Is > 22, Is <= 6
 
Label1.Caption = "TURNO DE NOCHE"
 
End Select
 
End Sub

Pero me da poblemas y el algunos casos siendo las 3 de la mañana me pone "TURNO DE MAÑANA" en vez de noche.

¿Como se rectifica el código para que funcione bien en todas las horas?

Gracias.
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
Imágen de perfil de Matias Emanuel

PONER TEXTO EN UN LABEL

Publicado por Matias Emanuel (13 intervenciones) el 11/08/2015 23:17:23
buenas tardes, este código debería funcionar. Cualquier consulta avisame

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
Private Sub Command1_Click()
 
    Dim hora As Date
 
    hora = Format(DateTime.Time, "hh:mm:ss ampm")
 
    If hora >= "06:00:00 am" And hora <= "11:59:59 am" Or hora >= "00:00:00 pm" And hora < "02:00:00 pm" Then
 
        Label1.Caption = "TURNO DE MAÑANA"
 
    Else
        If hora >= "02:00:00 pm" And hora < "08:00:00 pm" Then
 
            Label1.Caption = "TURNO DE TARDE"
 
        Else
           If hora >= "08:00:00 pm" And hora <= "11:59:59 pm" Or hora >= "00:00:00 am" And hora < "06:00:00 am" Then
 
                Label1.Caption = "TURNO DE NOCHE"
 
            End If
        End If
    End If
 
End Sub
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