Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Building the OnKeyDown property at runtime

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
US
At runtime I would like to set the OnKeyDown property of a combobox to a predefined function. I know I can set it at design time, but I need to set it at runtime, but I'm not sure of the syntax. Note that the OnKeyDown event is expecting 2 values (KeyCode and Shift). I tried to set it to this with limited results
Code:
cbo.OnKeyDown = eval("ComboBox_OnKeyDown()")

My code would look like this:
Code:
Function ComboBox_OnKeyDown()

blah blah blah

End function

This sort of works, but how do i code it so that it will receive the 2 arguments (KeyCode and Shift)?
 
Would this work?
Code:
Private Sub txtWhatever_KeyDown(KeyCode As Integer, Shift As Integer)
   Select Case WhoDoesItGoTo
      Case IsItMe
         FirstProcedure KeyCode, Shift
      Case OrIsItMe
         SecondProcedure KeyCode, Shift
   End Select
End Sub

 
JoeAtWork, that wouldn't work in my case because I don't know the names of the procedures prior to runtime. The reason being, this will be a library routine that other developers can also use.

I think that if I can't do what I want, I will just create a wizard that creates the control for me with the OnKeyDown property set correctly. It will also add the code to the form's module.

Thanks anyway, JoeAtWork.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top