• 0

[VB.NET] Making all letters Capital on Keypress


Question

i am trying to figure out how to do this..

in VB6 it was:

KeyAscii = Asc(UCase$(Chr$(KeyAscii)))

also...how do i make shortcut keys work? so like Ctrl+A = Select all text.

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

There is a method called ".SelectAll()".

Create a Menu. Call it "Select All". Add a Shortcut Key to it CTRL+A from the properites pane. Code the menu.

Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
        TextBox1.SelectAll()
End Sub

The above code will execute when the "Select All" menu is selected or when the user presses CTRL+A. The outcome of this code will select all the text in the textbox in the picture. :)

Edited by xStainDx
Link to comment
Share on other sites

  • 0

this is the code i use for textbox named txtnote:

   Private Sub txtNote_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtNote.KeyDown
        If e.KeyCode = Keys.A AndAlso e.Modifiers = Keys.Control Then
            txtNote.SelectAll()
        End If
    End Sub

Link to comment
Share on other sites

  • 0
this is the code i use for textbox named txtnote:

   Private Sub txtNote_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtNote.KeyDown
        If e.KeyCode = Keys.A AndAlso e.Modifiers = Keys.Control Then
            txtNote.SelectAll()
        End If
    End Sub

that did nothing... :(

Link to comment
Share on other sites

  • 0
that did nothing... :(

if you have the textbox active and have replaced txtnote with the name of your textbox, it will select all the text. That's wha tto code does since that's what you asked. I know it works, I use it in NexNote.

Link to comment
Share on other sites

  • 0
if you have the textbox active and have replaced txtnote with the name of your textbox, it will select all the text. That's wha tto code does since that's what you asked. I know it works, I use it in NexNote.

the reason it didnt work is because ctrl A was being reserved.

it DOES work..except it does a beep() everytime you select all...

Link to comment
Share on other sites

  • 0
yes yes..it works now..but now it beeps every time i use it.

Well it shouldn't. Use a different combination then.

Link to comment
Share on other sites

  • 0

For capitalization, look at the "CharacterCasing" property of the WinForms text box control. You can set it from within the Windows Forms designer.

The "ActiveControl" property of the "Form" class will tell you what the active control (if any) is on a form. It's a fairly trivial matter to check whether this is a text box and if so, to select the contents of that text box.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.