here u go!
Private Sub TextBox3_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
Dim str As String = ""
Dim substr As String = ""
Dim i As Integer = 0
str = TextBox3.Text
i = str.Length
If (str.Length > 6) Then
TextBox3.Text = str.Substring(0, str.Length - 1)
TextBox3.SelectionStart = TextBox3.Text.ToString.Length
Return
End If
If str <> "" Then
substr = str.Substring(str.Length - 1, 1)
If (i Mod 2 = 0) Then
If Not (IsNumeric(substr)) Then
TextBox3.Text = str.Substring(0, str.Length - 1)
TextBox3.SelectionStart = TextBox3.Text.ToString.Length
Exit Sub
End If
Else
If (IsNumeric(substr)) Then
TextBox3.Text = str.Substring(0, str.Length - 1)
TextBox3.SelectionStart = TextBox3.Text.ToString.Length
Exit Sub
End If
End If
End If
End Sub
|