Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

what's the code at the keypress event that'll make a pressed lowercase letter uppercase. here is what tried, which obviously doesn't work but you get the idea:

   Private Sub TextBox_KeyPress(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox.KeyPress
       If e.KeyChar.IsLower(e.KeyChar) Then e.KeyChar = e.KeyChar.ToUpper(e.KeyChar)
   End Sub

To err is human, to really foul things up requires a computer.
Posted

here's what i did which works:

       If e.KeyChar.IsLower(e.KeyChar) Then
           e.Handled = True
           TextBox.Text &= e.KeyChar.ToUpper(e.KeyChar)
           SendKeys.Send("{END}")
       End If

The pressing END key is so the caret is at the end of the textbox instead of the start.

To err is human, to really foul things up requires a computer.
Posted
You can also set the text box properties to upper case then all characters appear in the box will be upper. You don't have to manually convert them :-).
  • *Experts*
Posted
You shouldn't simply concatenate the key pressed, since the caret could be in the middle of the textbox. Set the CharacterCasing property to Upper, as that will handle pasting text as well.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...