Compiler chokes on correct syntax TreeView1_KeyDown(KeyCode AsInteger, Shift As Integer).

B

baobob

My Excel 2002 VB Editor has Microsoft Visual Basic 6.3.

I've been using TreeView months and it works great. Now I want to use
KeyDown. VB 6.3 Help says syntax is:

"Event KeyDown(KeyCode As Integer, Shift As Integer)"

So I have:

[In Form Module UserForm1:]
Private Sub TreeView1_KeyDown(KeyCode As Integer, Shift As Integer)

But the compiler chokes on that line with:

"Procedure declaration does not match description of event or
procedure having the same name" [terminated without punctuation]

Besides the complaint that it'd take only half those words for the
stupid error msg. to tell you what the syntax *is*, I've tried several
variations and they all choke too, e.g.:

Private Sub TreeView1_KeyDown(

ByVal KeyCode As Integer, ByVal Shift As Integer
KeyCode As ReturnInteger, Shift As Integer
ByVal KeyCode As ReturnInteger, ByVal Shift As Integer
KeyCode As MSForms.ReturnInteger, Shift As Integer
ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer
KeyAscii As Integer, Shift As Integer
ByVal KeyAscii As Integer, ByVal Shift As Integer
ByVal
If_You_Want_Me_To_Say_George_Bush_Is_A_Great_President_Then_OK_He_Is
As String

)

Yet right above it in the same module I've been using:

Private Sub TreeView1_KeyPress(KeyAscii As Integer)

and it compiles fine.

Full disclosure dept.: I'm implementing UserForm thru Stephen Bullen's
great CFormChanger, but all he does is set some simple sizing & button
properties & methods at the form level.

What am I doing wrong?

Thanks much.

***
 
B

Bob Bridges

Unless I'm missing something (and I'm kinda new here), this is a VBA forum
and you're asking about VB code. Little do I know of the KeyDown and
KeyPress events (except as I used them in VBA/Access), and nothing at all of
TreeView whatever that is, but I note you say the documentation asks for
"KeyDown(...)" and you're supplying "TreeView1_KeyDown(...)". Could it be so
simple as that? I have no VB 6.3 documentation I can go to to compare the
syntax for the two events.
 
J

Josh Sale

Try using the following to define your event handler:

ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer

josh
 

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