Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   hour vb.net (http://www.go4expert.com/forums/hour-vbnet-t29585/)

1912Dummy 30Mar2013 23:38

hour vb.net
 
Hello,
does anyone known's why this don't work?
Code:

Dim d As DateTime = DateTime.Now
        Dim time = d.Hour
        If (time < 12) Then

            lbltime.Text = "Good Morning"

        ElseIf (time >= 12 Or time < 18) Then

            lbltime.Text = "Good Afternoon"

        ElseIf (time >= 18 Or time < 23) Then
            lbltime.Text = "Good Evening"
        Else
            lbltime.Text = "Good Night"

        End If

even when the time is 19h it still says good afternoon instead of good evening
anyone please?

thanks

1912Dummy 31Mar2013 05:13

Re: hour vb.net
 
well thanks anyway guys
i got it working.

Code:

Dim d As DateTime = DateTime.Now
        Dim time = d.Hour

        If (time >= 6 And time < 12) Then

            lbltime.Text = "Good Morning"

        ElseIf (time >= 12 And time < 18) Then

            lbltime.Text = "Good Afternoon"

        ElseIf (time >= 18 And time < 23) Then
            lbltime.Text = "Good Evening"
        Else
            lbltime.Text = "Good Night"

        End If



All times are GMT +5.5. The time now is 20:39.