With command : With « Language Basics « VB.Net






With command

With command
Imports System.IO

Module Module1

    Sub Main()
        Dim t As Today = New Today
        With t
            Console.WriteLine("Today: " & .TodayDate)
            Console.WriteLine("Day: " & .Day)
            Console.WriteLine("Month: " & .Month)
            Console.WriteLine("Year: " & .Year)
            Console.WriteLine("Day of week: " & .NumericDayOfWeek)
            Console.WriteLine("Day of week: " & .StringDayOfWeek)
        End With
    End Sub

End Module

    Class Today
        Public Shared TodayDate As DateTime = Now()
        Public Shared Day As Integer = Now.Day()
        Public Shared Month As Integer = Now.Month()
        Public Shared Year As Integer = Now.Year()
        Public Shared NumericDayOfWeek As Integer = Now.DayOfWeek()

        Public Shared StringDayOfWeek As String = Now.DayOfWeek.ToString()
    End Class

           
       








Related examples in the same category