G
Gerry Viator
Hi all,
I would like only a year in a range from 1950 to 2040 to be alowed in a
textbox control.
This doesn't seam to be working...
Private Sub txtboxYear_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txtboxYear.KeyDown
Dim strKey As String
strKey = e.KeyCode.ToString().Remove(0,
e.KeyCode.ToString().Length - 1)
If txtboxYear.Text <> Nothing Then
Dim FirstNumb As String
Dim SecondNumb As String
Dim ThirdNumb As String
Dim FourthNumb As String
If txtboxYear.Text.Length = 1 Then
If strKey = "1" Or strKey = "2" Then
Else
e.Handled = True
End If
ElseIf txtboxYear.Text.Length = 2 Then
If strKey = "0" Or strKey = "9" Then
Else
e.Handled = True
End If
ElseIf txtboxYear.Text.Length = 3 OrElse txtboxYear.Text.Length
= 4 Then
If strKey > "0" And strKey <= "9" Then
Else
e.Handled = True
End If
End If
Else
If strKey = "1" Or strKey = "2" Then
Else
e.Handled = True
End If
End If
End Sub
can someone help thanks
Gerry
I would like only a year in a range from 1950 to 2040 to be alowed in a
textbox control.
This doesn't seam to be working...
Private Sub txtboxYear_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txtboxYear.KeyDown
Dim strKey As String
strKey = e.KeyCode.ToString().Remove(0,
e.KeyCode.ToString().Length - 1)
If txtboxYear.Text <> Nothing Then
Dim FirstNumb As String
Dim SecondNumb As String
Dim ThirdNumb As String
Dim FourthNumb As String
If txtboxYear.Text.Length = 1 Then
If strKey = "1" Or strKey = "2" Then
Else
e.Handled = True
End If
ElseIf txtboxYear.Text.Length = 2 Then
If strKey = "0" Or strKey = "9" Then
Else
e.Handled = True
End If
ElseIf txtboxYear.Text.Length = 3 OrElse txtboxYear.Text.Length
= 4 Then
If strKey > "0" And strKey <= "9" Then
Else
e.Handled = True
End If
End If
Else
If strKey = "1" Or strKey = "2" Then
Else
e.Handled = True
End If
End If
End Sub
can someone help thanks
Gerry