Mega Code Archive

 
Categories / VB.Net Tutorial / Date Time
 

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 < 12) Then             Console.Writeline("Good Morning!")         End If         If (iHour >= 12) And (iHour < 18) Then             Console.WriteLine("Good Afternoon!")         End If         If (iHour >= 18) Then             Console.WriteLine("Good Evening!")         End If     End Sub End Class Good Afternoon!