Option Explicit On Option Strict On Public Class MainForm Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click Me.Close() End Sub Private Sub monthTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles monthTextBox.Enter monthTextBox.SelectAll() End Sub Private Sub monthTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles monthTextBox.TextChanged daysLabel.Text = String.Empty End Sub Private Sub displayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles displayButton.Click Dim month() As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Dim day() As Integer = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} Dim num As Integer Dim isconverted As Boolean isconverted = Integer.TryParse(monthTextBox.Text, num) If isconverted AndAlso num >= 1 AndAlso num <= 12 Then daysLabel.Text = Convert.ToString(day(num - 1)) MessageBox.Show("invalid month number", "Months", MessageBoxButtons.OK, MessageBoxIcon.Information) End If End Sub End Class