i need to create some code, that will do the following. The user inputs only numbers, which i have coded with the key press event. Next is the length of the date can only be 8 characters long. mm/dd/yy Also inside this condition i need to have the month, day and year be stored in different variables so that i can validate individually if the correct date for each month, day, and year are correct. for instance we don't have more than 12 months in a year. So i was thinking about using substring to pull apart the one variable that holds the input of the textbox then validate individually.
I do realize that there is built-in functions but in this case i am not allowed to use them.
Private Sub btnCheckDate_Click(sender As Object, e As EventArgs) Handles btnCheckDate.Click
Dim strDate As String
Dim badDate As Boolean = False
strDate = txtInput.TabIndex
If strDate.Length <> 8 Then
MessageBox.Show("Bad date")
txtInput.Text = String.Empty
txtInput.Focus()
End If
Dim intMonth As Integer
Dim intDay As Integer
Dim intYear As Integer
intMonth = CInt(strDate.Substring(0, 2))