Hi
I have a broblem with my label text.
The code is
Public Class Form5
Dim a As Integer
Dim currentDate As DateTime = DateTime.Now
Dim jaarnu As Integer = currentDate.Year
Private timeLeft As Integer
Dim WithEvents timer As New Timer
Dim milliseconds As Integer
Dim monthnumber As Integer
Dim v As Integer
Dim h As Integer
Dim maand As Integer
Dim dagnummer As Integer
Dim montnaam As Integer
Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
timeLeft = 10
Label30.Text = jaarnu
Dim currentDate As DateTime = DateTime.Now
Dim days As Integer = currentDate.Date.Month
Dim dagmaadn As String = String.Format("{0:dddd d MMMM}", DateTime.Now)
ComboBox10.Text = String.Format("{0:MMMM}", DateTime.Now)
Label28.Text = String.Format("{0:dddd d MMMM yyyy}", DateTime.Now)
Label29.Text = dagmaadn
Label29.Location = New System.Drawing.Point(Label30.Location.X - Label29.Width - 5, Label30.Location.Y)
End Sub
Private Sub ComboBox10_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox10.SelectedIndexChanged
If Label30.Text <> "" Then
If ComboBox10.Text = "januari" Then
monthnumber = 1
Dim maandnummer = 1
Dim jaar = Label30.Text
Dim Month As Integer = Now.Month
If maandnummer > Month And jaar = Date.Now.ToString("yyyy") Then
ComboBox10.Items.Clear()
ComboBox10.Items.Add("januari")
ComboBox10.Items.Add("februari")
ComboBox10.Items.Add("maart")
ComboBox10.Items.Add("april")
ComboBox10.Items.Add("mei")
ComboBox10.Items.Add("juni")
ComboBox10.Items.Add("juli")
ComboBox10.Items.Add("augustus")
ComboBox10.Items.Add("september")
ComboBox10.Items.Add("oktober")
ComboBox10.Items.Add("november")
ComboBox10.Items.Add("december")
ComboBox10.Text = DateTime.Today.ToString("MMMM")
MessageBox.Show(("De gekozen maand januari ") & Date.Now.ToString("yyyy") & (" kunt u niet kiezen. U kunt alleen de huidige maand of eerder dan ") & Date.Now.ToString("y") & (" kiezen."))
Exit Sub
End If
If ComboBox10.Text = "januari" Then
Button31.Visible = True
Button30.Visible = True
Button29.Visible = True
Dim s As String = Label29.Text
s = s.Split(" ".ToCharArray)(1)
Dim dat As Date = s & " " & monthnumber & " " & Label30.Text
Dim nieuwedatum As String = (dat.ToString("dddd d MMMM"))
If Label30.Text = jaarnu Or Label30.Text > jaarnu Then
For i As Integer = 1 To 31
CType(Me.Controls.Find(String.Format("Button{0}", i), True)(0), Button).BackColor = SystemColors.Control
CType(Me.Controls.Find(String.Format("Button{0}", i), True)(0), Button).UseVisualStyleBackColor = True
Next
End If
CType(Me.Controls.Find(String.Format("Button" & s), True)(0), Button).UseVisualStyleBackColor = True
CType(Me.Controls.Find(String.Format("Button" & s), True)(0), Button).BackColor = Color.LightBlue
CType(Me.Controls.Find(String.Format("Button" & s), True)(0), Button).Select()
Label29.Text = nieuwedatum
Label29.Location = New System.Drawing.Point(Label30.Location.X - Label29.Width - 5, Label30.Location.Y)
End If
End If
If ComboBox10.Text = "februari" Then
monthnumber = 2
Dim maandnummer = 2
Dim jaar = Label30.Text
Dim Month As Integer = Now.Month
If maandnummer > Month And jaar = Date.Now.ToString("yyyy") Then
ComboBox10.Items.Clear()
ComboBox10.Items.Add("januari")
ComboBox10.Items.Add("februari")
ComboBox10.Items.Add("maart")
ComboBox10.Items.Add("april")
ComboBox10.Items.Add("mei")
ComboBox10.Items.Add("juni")
ComboBox10.Items.Add("juli")
ComboBox10.Items.Add("augustus")
ComboBox10.Items.Add("september")
ComboBox10.Items.Add("oktober")
ComboBox10.Items.Add("november")
ComboBox10.Items.Add("december")
ComboBox10.Text = DateTime.Today.ToString("MMMM")
MessageBox.Show(("De gekozen maand februari ") & Date.Now.ToString("yyyy") & (" kunt u niet kiezen. U kunt alleen de huidige maand of eerder dan ") & Date.Now.ToString("y") & (" kiezen."))
Exit Sub
End If
If ComboBox10.Text = "februari" Then
monthnumber = 2
Dim jaarx As Integer = Label30.Text ' gegeven jaartal.
Dim jaara = jaarx / 4
Dim jaarb = jaarx / 100
Dim jaarc = jaarx / 400
If jaara = (Int(jaara) And jaarb <> Int(jaarb)) Or jaarc = Int(jaarc) Then
For I = 1 To 29
Button31.Visible = False
Button30.Visible = False
Button29.Visible = True
Next
Else
For I = 1 To 28
Button31.Visible = False
Button30.Visible = False
Button29.Visible = False
Next
End If
Dim s As String = Label29.Text
s = s.Split(" ".ToCharArray)(1)
Dim dat As Date = s & " " & monthnumber & " " & Label30.Text
Dim nieuwedatum As String = (dat.ToString("dddd d MMMM"))
If Label30.Text = jaarnu Or Label30.Text > jaarnu Then
For i As Integer = 1 To 31
CType(Me.Controls.Find(String.Format("Button{0}", i), True)(0), Button).BackColor = SystemColors.Control
CType(Me.Controls.Find(String.Format("Button{0}", i), True)(0), Button).UseVisualStyleBackColor = True
Next
End If
CType(Me.Controls.Find(String.Format("Button" & s), True)(0), Button).UseVisualStyleBackColor = True
CType(Me.Controls.Find(String.Format("Button" & s), True)(0), Button).BackColor = Color.LightBlue
CType(Me.Controls.Find(String.Format("Button" & s), True)(0), Button).Select()
Label29.Text = nieuwedatum
Label29.Location = New System.Drawing.Point(Label30.Location.X - Label29.Width - 5, Label30.Location.Y)
End If
End If
If ComboBox10.Text = "maart" Then
monthnumber = 3
Dim maandnummer = 3
Dim jaar = Label30.Text
Dim Month As Integer = Now.Month
If maandnummer > Month And jaar = Date.Now.ToString("yyyy") Then
ComboBox10.Items.Clear()
ComboBox10.Items.Add("januari")
ComboBox10.Items.Add("februari")
ComboBox10.Items.Add("maart")
ComboBox10.Items.Add("april")
ComboBox10.Items.Add("mei")
ComboBox10.Items.Add("juni")
ComboBox10.Items.Add("juli")
ComboBox10.Items.Add("augustus")
ComboBox10.Items.Add("september")
ComboBox10.Items.Add("oktober")
ComboBox10.Items.Add("november")
ComboBox10.Items.Add("december")
ComboBox10.Text = DateTime.Today.ToString("MMMM")
MessageBox.Show(("De gekozen maand maart ") & Date.Now.ToString("yyyy") & (" kunt u niet kiezen. U kunt alleen de huidige maand of eerder dan ") & Date.Now.ToString("y") & (" kiezen."))
Exit Sub
End If
If ComboBox10.Text = "maart" Then
monthnumber = 3
Button31.Visible = True
Button30.Visible = True
Button29.Visible = True
End If
Dim s As String = Label29.Text
s = s.Split(" ".ToCharArray)(1)
Dim dat As Date = s & " " & monthnumber & " " & Label30.Text
Dim nieuwedatum As String = (dat.ToString("dddd d MMMM"))
If Label30.Text = jaarnu Or Label30.Text > jaarnu Then
For i As Integer = 1 To 31
CType(Me.Controls.Find(String.Format("Button{0}", i), True)(0), Button).BackColor = SystemColors.Control
CType(Me.Controls.Find(String.Format("Button{0}", i), True)(0), Button).UseVisualStyleBackColor = True
Next
End If
CType(Me.Controls.Find(String.Format("Button" & s), True)(0), Button).UseVisualStyleBackColor = True
CType(Me.Controls.Find(String.Format("Button" & s), True)(0), Button).BackColor = Color.LightBlue
CType(Me.Controls.Find(String.Format("Button" & s), True)(0), Button).Select()
Label29.Text = nieuwedatum
Label29.Location = New System.Drawing.Point(Label30.Location.X - Label29.Width - 5, Label30.Location.Y)
End If
End If
End Sub
End Class
My question is why is label29.text empty ?
when i leave the code
Private Sub ComboBox10_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
bla
bla
End sub
away then my label29.text is loading
Thanks in advice John