1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

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