I am trying to make my main form of my project, which is an MDI Container, show me in a StatusLabel, which is contained in its StatusStrip, a countdown of what is needed to start the next month. I have tried to do it but I can not find the result .. because it shows me how much is needed but so that two more months arrive ... and besides that ... I do not know how to consider that not every month has the same amount of days .. could someone help me? How could I do it? I attach what I have ...
Imports System.Globalization
Imports System.Text
Public Class Main
Dim culture As CultureInfo = CultureInfo.GetCultureInfo("es-ES")
Dim fechaLimite As Date = Date.ParseExact("01/10/2015 00:00:00", "dd/MM/yyyy hh:mm:ss", culture, DateTimeStyles.None)
Private Sub Main_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim dateDiff As TimeSpan = fechaLimite.Subtract(Date.Now)
Dim dateFormat As String = "dddd dd, MMMM, yyyy"
Dim sb As New StringBuilder
With sb
.AppendFormat("Fecha Actual: {0}", Date.Today.ToString(dateFormat, culture))
.AppendLine()
.AppendFormat("Fecha Límite: {0}", fechaLimite.ToString(dateFormat, culture))
.AppendLine()
.AppendFormat("Quedan: {0}", String.Format("{0:0}d. {1:00}h. {2:00}m. {3:00}s.",
dateDiff.TotalDays, dateDiff.Hours,
dateDiff.Minutes, dateDiff.Seconds))
End With
Me.StatusLabel1.Text = sb.ToString
End Sub