Intercepting The Enter Key in A ComboBox

Category:
Forms and Controls
Type:
Snippets
Difficulty:
Beginning
Author:
Ch3z

Version Compatibility: Visual Basic 6

More information:
There are many ways to intercept the Enter key in a combobox, which applies to some other controls and some other keys as well, but this seems pretty simple. All your doing is basically setting the default button in realtime without messing with the resource editor. Simply set the "Default" property of the button you want to use upon the user pressing enter while this combobox has focus. This snippet also sets that value back to false after execution.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: