hour vb.net

Discussion in 'Visual Basic ( VB )' started by 1912Dummy, Mar 30, 2013.

  1. 1912Dummy

    1912Dummy New Member

    Joined:
    Mar 29, 2013
    Messages:
    7
    Likes Received:
    1
    Trophy Points:
    0
    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
     
  2. 1912Dummy

    1912Dummy New Member

    Joined:
    Mar 29, 2013
    Messages:
    7
    Likes Received:
    1
    Trophy Points:
    0
    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
    
     
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice