Re: Allow entering uppercase only

Tech-Archive recommends: Fix windows errors by optimizing your registry



Rob wrote:
> Is there an easy way to ensure that only Upper case characters are
> entered into a tex box ?

You could try this:

\\\
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

TextBox1.SelectedText = UCase(e.KeyChar)
e.Handled = True

End Sub
///

That seems to work fine. Note that text that the user pastes in will not be
affected by this so you probably want to follow Cor's recommendation too
when the user clicks the OK button on your form.

--

(O) e n o n e


.


Quantcast