Friday 30 September 2011

Get Hour from DateTime

Imports System

Public Class Greeting
     Shared Sub Main()
        Dim dtCurrent As System.DateTime
        Dim iHour As Integer

        dtCurrent = dtCurrent.Now()
        iHour = dtCurrent.Hour

        If (iHour < 12Then
            Console.Writeline("Good Morning!")
        End If
        If (iHour >= 12And (iHour < 18Then
            Console.WriteLine("Good Afternoon!")
        End If
        If (iHour >= 18Then
            Console.WriteLine("Good Evening!")
        End If
    End Sub

End Class

No comments:

Post a Comment