ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   RichTexBox1_KeyDown Event Not Working (https://www.excelbanter.com/excel-programming/345734-richtexbox1_keydown-event-not-working.html)

Trip[_3_]

RichTexBox1_KeyDown Event Not Working
 
Hi all,

I'm trying to get the KeyDown event to fire on a RichTextBox. Here's
my test code...

Private Sub Richtextbox1_Keydown(KeyCode As Integer, Shift As Integer)

MsgBox "hello"

End Sub

This is how it would be written in VB. Any suggestions for VBA??
Perhaps I need additional references??

Thanks!

Trip


Peter T

RichTexBox1_KeyDown Event Not Working
 
Hi Trip,

Your code works as expected for me. First I get the msgbox then whatever key
gets added to the text (where the cursor was) in the RTB.

If you are distributing a vba project with a RichTextBox control you might
be interested to read this thread

http://tinyurl.com/ayu97

Regards,
Peter T

"Trip" wrote in message
oups.com...
Hi all,

I'm trying to get the KeyDown event to fire on a RichTextBox. Here's
my test code...

Private Sub Richtextbox1_Keydown(KeyCode As Integer, Shift As Integer)

MsgBox "hello"

End Sub

This is how it would be written in VB. Any suggestions for VBA??
Perhaps I need additional references??

Thanks!

Trip




Peter T

RichTexBox1_KeyDown Event Not Working
 
I should have pasted your code rather than adding the event from the
dropdown. Your example is missing "ByVal" before the Shift

Private Sub Richtextbox1_Keydown(KeyCode As Integer, Shift As Integer)


Private Sub Richtextbox1_Keydown(KeyCode As Integer, ByVal Shift As Integer)

Regards,
Peter T

"Peter T" <peter_t@discussions wrote in message
...
Hi Trip,

Your code works as expected for me. First I get the msgbox then whatever

key
gets added to the text (where the cursor was) in the RTB.

If you are distributing a vba project with a RichTextBox control you might
be interested to read this thread

http://tinyurl.com/ayu97

Regards,
Peter T

"Trip" wrote in message
oups.com...
Hi all,

I'm trying to get the KeyDown event to fire on a RichTextBox. Here's
my test code...

Private Sub Richtextbox1_Keydown(KeyCode As Integer, Shift As Integer)

MsgBox "hello"

End Sub

This is how it would be written in VB. Any suggestions for VBA??
Perhaps I need additional references??

Thanks!

Trip






Trip[_3_]

RichTexBox1_KeyDown Event Not Working
 
Thanks for checking-out my code Peter! I have the RICHTX32.OCX
reference, yet, when I try to launch the form I get:

"Compile error: procedure declaration does not match description of
event or procedure haveing the same name"

Any further ideas??

Thanks,

Trip


Trip[_3_]

RichTexBox1_KeyDown Event Not Working
 
Thanks for checking-out my code Peter! I have the RICHTX32.OCX
reference, yet, when I try to launch the form I get:

"Compile error: procedure declaration does not match description of
event or procedure haveing the same name"

Any further ideas??

Thanks,

Trip


Trip[_3_]

RichTexBox1_KeyDown Event Not Working
 
Bingo!! Sorry for the additional post - this came in as I was writing.

Thanks! That did it!

Trip



All times are GMT +1. The time now is 08:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com