bioshock Posted January 7, 2010 at 03:24 PM Report Share #304629 Posted January 7, 2010 at 03:24 PM O exemplo abaixo que vos mostro, é facilmente compreensível, o problema é que não consigo fazer o que digo no código..alguma solução?? Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label1.Text = TimeOfDay.Hour If Label1.Text >= "6:00:00" Or Label1.Text <= "11:59:59" Then Label2.Text = "Boa dia" Else If Label1.Text >= "12:00:00" Or Label1.Text <= "19:59:59" Then Label2.Text = "Boa tarde" Else If Label1.Text >= "20:00:00" Or Label1.Text <= "5:59:59" Then Label2.Text = "Boa noite" End If End If End If End Sub Obrigado Link to comment Share on other sites More sharing options...
Weasel Posted January 7, 2010 at 05:16 PM Report Share #304648 Posted January 7, 2010 at 05:16 PM Aqui funciona... Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label1.Text = TimeOfDay.Hour If Label1.Text >= "6" Or Label1.Text <= "11" Then Label2.Text = "Bom dia" Else If Label1.Text >= "12" Or Label1.Text <= "19" Then Label2.Text = "Boa tarde" Else If Label1.Text >= "20" Or Label1.Text <= "5" Then Label2.Text = "Boa noite" End If End If End If End Sub Knowledge to the masses Link to comment Share on other sites More sharing options...
jpaulino Posted January 7, 2010 at 06:37 PM Report Share #304654 Posted January 7, 2010 at 06:37 PM Não será AND em vez de OR ? E depois o pessoal tem de se habituar a trabalhar como deve ser. Converter horas para uma string para depois comparar com string não é uma boa prática. Tenta assim: Dim tspan As TimeSpan = Now.TimeOfDay If tspan >= New TimeSpan(6, 0, 0) AndAlso tspan <= New TimeSpan(11, 0, 0) Then Label1.Text = "Bom Dia" ElseIf tspan >= New TimeSpan(12, 0, 0) AndAlso tspan <= New TimeSpan(19, 0, 0) Then Label1.Text = "Boa Tarde" Else Label1.Text = "Boa Noite" End If Link to comment Share on other sites More sharing options...
bioshock Posted January 7, 2010 at 07:12 PM Author Report Share #304661 Posted January 7, 2010 at 07:12 PM Obrigado, é mesmo isso! Cumprimentos 😕 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now