-
Notifications
You must be signed in to change notification settings - Fork 2
Events
Event procedures are special subroutines that objects call automatically when a pre-defined action occurs.
None
None
The Activate event is raised when an object becomes the active window. The Initialize event occurs first, when the object is initialized. The Load event occurs next and is often used to initialize any subcomponents or controls. The Activate event occurs after the Load event, and then each time the object becomes the active window.
Deactivate occurs each time an object becomes a non-active window.
The Change Event method...
None
None
The Click event is raised when the object is clicked with the primary mouse button (usually the left) and the mouse button is released while the mouse pointer is still over the object. In some instances, for example with the Command Button, the click event will also be raised when the object has focus and the Enter key or Spacebar is pressed.
The click event is also raised if the object has focus and the Enter key or SpaceBar is pressed.
The click event is also raised if the object has focus a list item is selected using the arrow keys.
The click event is also raised when the CheckBox has focus and the SpaceBar is pressed.
The click event is also raised when the arrow keys are used to select an Option Button within a group.
The click event is also raised when the object is clicked with the secondary mouse button. However, depending on the operating system, a context menu may display first and the click event is raised when the context menu is dismissed, or one of the context menu items is selected.
The click event is only raised when the primary (usually left) mouse button clicks on the frame object. If any controls inside the frame are clicked, the clicked control will receive the event and the click event for the frame will not be called.
The click event is only raised by a mouse click when the primary (usually left) mouse button clicks on the object. If the object has focus, the SpaceBar and arrow keys will also cause the click event to be raised.
The click event is raised by a mouse click of either mouse button on the object. If the object has focus, the SpaceBar and arrow keys will also cause the click event to be raised.
the DblClick event is raised when the primary (usually left) mouse button is pressed quickly over an object twice.
The DblClick event occurs when the user double-clicks an empty area of a form or on a disabled control.
Double-clicks on a ComboBox only raise the DblClick event if the ComboBox Style is set to vbComboSimple.
The DropDown Event method...
None
None
The GotFocus event is raised when the object receives the focus. The object can get focus when it is clicked with the mouse, or by the user tabbing into the object. When an object has focus, it will receive input from the keyboard.
None
None
The initialize event is raised when the object is initialized during the form load. This event is useful to populate the object with data or otherwise prepare it for the user.
- KeyCode: Integer - the ASCII value of the key pressed.
- Shift: KeyMask - the bitwise value representing all of the shifting keys pressed.
None
The KeyDown event is the first of the key events to be raised and occurs when the key is pressed down. The KeyDown event passes in the KeyCode and the Shift state. The KeyCode represents the ASCII value of the key that was pressed. The Shift parameter represents which of the three "shift" keys were also pressed. The possible values of Shift are: 1 = Shift Key, 2 = CTRL key, and 4 = ALT key. Bitwise logic can be used to determine if more than one key was being pressed. The code below can be used to determine which shifting keys are pressed:
Private Sub Object1_KeyDown(KeyCode As Integer, Shift As Integer) Handles Object1.KeyDown
Dim bShift As Boolean = vbShiftMask And Shift > 0
Dim bAlt As Boolean = vbAltMask And Shift > 0
Dim bCtrl As Boolean = vbCtrlMask And Shift > 0
'Add logic here that uses the boolean values to suit your needs.
End SubNote: the KeyCode represents the key pressed, not the ASCII value for the character. Because of this, a lower-case and upper-case letter will have the same KeyCode value. Use the Shift value to determine if the shift key was down, if necessary. The KeyUp event is the final key event to be raised and occurs when the user releases the key. The KeyUp event has the same inputs as the KeyDown. If a form's KeyPreview property is set to TRUE, the form will receive the Key events before the control does.
- KeyASCII: Integer - the ASCII value of the key pressed.
The KeyPress event is similar to the KeyDown, but it happens after the KeyDown event and it passes in the ASCII value of the key pressed via the KeyASCII property. Unlike the KeyDown and KeyUp events, the ASCII value passed into the KeyPress event will be case sensitive. Setting this property to 0 (zero) within the keypress event will nullify the keypress and, effectively, ignore it.
The LostFocus event is raised when the object loses focus. An object can lose focus when the user clicks the mouse on something else or uses the tab key to move the input selector.
- Button: Integer - the ASCII value of the key pressed.
- Shift: Integer - the bitwise value representing all of the shifting keys pressed.
- X: Integer - the number of pixels the mouse is from the left edge of the object's container
- Y: Integer - the number of pixels the mouse is from the top edge of the object's container
None
The MouseDown event is raised when the mouse button is pressed while over the object. The MouseUp event is raised when the mouse button is released.
- Button: Integer - the ASCII value of the key pressed.
- Shift: Integer - the bitwise value representing all of the shifting keys pressed.
- X: Integer - the number of pixels the mouse is from the left edge of the object's container
- Y: Integer - the number of pixels the mouse is from the top edge of the object's container
The MouseMove event is raised when the mouse is moved over the object. The MouseMove event has several parameters that provide useful information to the event. The Button parameter is an integer value that represents which button was pressed. The possible values are 1 = Left button, 2 = Right button, and 4 = Center button. See the KeyDown event for information on using bitwise boolean logic to determine which buttons were pressed. The Shift parameter works the same way for the MouseMove as it does for the KeyPress. Again, see the KeyPress event for help determining which shifting keys are being pressed. The X and Y parameters provide the location of the mouse as it moves.
The Scroll method...