RichTexBox1_KeyDown Event Not Working

  • Thread starter Thread starter Trip
  • Start date Start date
T

Trip

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
 
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
 
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, ByVal Shift As Integer)

Regards,
Peter T
 
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
 
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
 
Bingo!! Sorry for the additional post - this came in as I was writing.

Thanks! That did it!

Trip
 

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

Back
Top