-
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.
None
None
The Change event is raised when the data in a control is changed
The Change event for a ComboBox is raised when the data in the textbox area of the combo box is edited.
Note: The Change event is not raised when an item is selected using a mouse or the keyboard. To detect a change in which item is selected use the Click event.
The Change event for a DirListBox and DriveListBox occur when the Path or Drive letter property is changed through code and when a directory or drive letter is double-clicked in the user interface.
The Change event for the horizontal and vertical scroll bars is raised when the Value property changes by setting the Value in code or when the scroll box within the scroll bar is moved in the user interface.
The Change event for a Label is raised when the label Caption is changed. The Change event for a PictureBox is raised when the picture in the box is changed. The Change event for both types of controls will raise if the control is bound to a source via DDE which is updated, or if it is changed through code.
The Change event is raised whenever the contents of the TextBox changes. This can happend via an update through the user interface, when the text is changed through code, or if the TextBox is bound via a link that updates the data.
None
None
The Click event is raised when the object is clicked with the primary mouse button 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. Note: If there is an event handler for the Click event with code in it, the DblClick event will not be raised.
The event order for the ListBox and CommandButton is MouseDown, Click, then MouseUp (Down-Click-Up). The event order for the FileListBox, Label, and PictureBox is MouseDown, MouseUp, and Click (Down-Up-Click).
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 if the object has focus and the Enter key or SpaceBar is pressed.
The click event is also raised when the CheckBox has focus and the SpaceBar is pressed.
The click event is only raised when the primary 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 also raised if the object has focus a list item is selected using the arrow keys.
The click event is also raised when the arrow keys are used to select an Option Button within a group.
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 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.
None
None
the DblClick event is raised when the primary 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.
- Source As Control - the control that was dropped
- X As Single - the X coordinate position of the mouse when the mouse button was released
- Y As Single - the Y coordinate position of the mouse when the mouse button was released
None
The DragDrop event is raised when a control is dragged over an object and the mouse button released. It will also be raised if the Drag method is used with its action argument set to 2 (Drop)
- Source As Control - the control that was dropped
- X As Single - the X coordinate position of the mouse when the mouse button was released
- Y As Single - the Y coordinate position of the mouse when the mouse button was released
- State As Integer TransitionState - the state of the move, Enter, Leave, or Over.
The DragOver Event method...
None
None
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. Use the TabOrder and TabIndex properties to determine if and when a control receives focus via the keyboard.
Note: a control can only receive focus if it is visible and enabled.
The Hide Event (UserControl Object) method...
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 Load Event method...
None
None
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: Button - the ASCII value of the key pressed.
- Shift: KeyMask - 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: Button - the ASCII value of the key pressed.
- Shift: KeyMask - 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. The X and Y parameters provide the location of the mouse as it moves.
The OLE Event...
The OLE Event...
The OLE Event...
The OLE Event...
The OLE Event...
The OLE Event...
The Paint Event method...
The Resize Event method...
None
None
The Scroll method...
The Timer Event method...