Ejercicio
Fecha y hora
Objetivo
Crear un programa para mostrar la fecha y hora actual con el siguiente formato:
Hoy es 6 de febrero de 2015. Son las 03:23:12
Código
Imports System
Class DateAndTime1
Private Shared Sub Main()
Dim day As String = DateTime.Now.Day.ToString("00")
Dim month As String = GetMonth(DateTime.Now.Month)
Dim year As Integer = DateTime.Now.Year
Dim time As String = DateTime.Now.ToLongTimeString()
Console.WriteLine("Today is {0} of {1} of {2}. It´s {3}.", day, month, year, time)
End Sub
Private Shared Function GetMonth(ByVal numberMonth As Integer) As String
Dim months As String() = New String() {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "Decenber"}
Return months(numberMonth - 1)
End Function
End Class