Gettin no KeyPress event

K

KC

I'm trying to build a simple text editor in part of my app. Right now I'm
just testing the basics of the KeyPress event handler. The code is
basic...real simple. I'm just testing stuff -
Private Sub txtConsole_KeyPress(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtConsole.KeyPress
Dim ch As Char
If System.Char.IsControl(e.KeyChar) Then Exit Sub
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
MsgBox(FTPline)
Else
FTPline = FTPline + e.KeyChar.ToString
End If
End Sub

The problem is the app never gets to the code. Why!? I went to the textbox
and chose the KeyPress event and then stuck the code in it. When I put a
breakpoint in the code it say the breakpoint will not be hit and, "No
symbols have been loaded for this document."??? Is this another one of those
VB.net 'improvements'??
 
H

Herfried K. Wagner [MVP]

* "KC said:
I'm trying to build a simple text editor in part of my app. Right now I'm
just testing the basics of the KeyPress event handler. The code is
basic...real simple. I'm just testing stuff -
Private Sub txtConsole_KeyPress(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtConsole.KeyPress
Dim ch As Char
If System.Char.IsControl(e.KeyChar) Then Exit Sub
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
MsgBox(FTPline)
Else
FTPline = FTPline + e.KeyChar.ToString
End If
End Sub

I am not sure what's the purpose of the code, but typically instead of
searching for 'ChrW(13)', a default button is used on the form. To do
that, assign a button to the form's 'AcceptButton' property. If the
textbox has focus and Return is pressed, the button's 'Click' event will
execute, and there you can get the text from the textbox and display it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top