MouseMove

This event occurs when a user moves the mouse device.

Syntax

Private Sub object_MouseMove(button, shift, x, y)

Parameters

object
Object expression that evaluates to a control or Form object.
button
Integer that corresponds to the state of the buttons of a mouse device, indicating that a user has pressed one, two, or none of the buttons.
shift
Integer that corresponds to the state of the SHIFT, CTRL, and ALT keys. A bit is set if the key is down.
x
Number that specifies the horizontal location of the pointer.
y
Number that specifies the vertical location of the pointer.

Remarks

The MouseMove event is generated continually as the pointer of a mouse device moves across objects. Unless another object captures the pointer, an object recognizes a MouseMove event whenever the pointer position is within its borders.

The following table shows the constants you can use to test for the button parameter.

Constant
Value
Description
vbLeftButton 1 Left button is pressed.
VbRightButton 2 Right button is pressed.
VbMiddleButton 4 Unsupported.

The following table shows the constants you can use to test for the shift parameter.

Constant
Value
Description
vbShiftMask 1 SHIFT key is pressed.
VbCtrlMask 2 CTRL key is pressed.
VbAltMask 4 ALT key is pressed.

The button parameter for MouseMove differs from the button parameter for MouseDown and MouseUp. For MouseMove, the button parameter indicates the current state of all buttons; a single MouseMove event indicates that a user has pressed some, all, or no buttons. For MouseDown and MouseUp, the button parameter indicates exactly one button per event.