Dim bolFoxStyle As Boolean = False Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress Dim strCur As String = sender.text.trim Dim ilenCur As Integer = strCur.Length Dim strNew As String = "" If bolFoxStyle Then If e.KeyChar.IsLetterOrDigit(e.KeyChar) Then If ilenCur >= sender.maxlength Then strNew = strCur.Substring(0, (ilenCur - 1)) & e.KeyChar sender.text = strNew ' sender.Select((sender.maxlength - 1), 1) ' This doesn't work here add to _textchanged End If End If Else If e.KeyChar.IsLetterOrDigit(e.KeyChar) Then If ilenCur >= sender.maxlength Then strNew = strCur.Substring(1, (ilenCur - 1)) & e.KeyChar sender.text = strNew TextBox1.SelectionStart = sender.maxlength ' Move to the end of the line for UI clarity End If End If End If End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged If bolFoxStyle Then Dim strCur As String = sender.text.trim Dim ilenCur As Integer = strCur.Length If ilenCur >= sender.maxlength Then sender.Select((sender.maxlength - 1), 1) ' This works here End If End If End Sub
"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams