MouseUp

This event occurs when a user releases a button on a mouse device.

Syntax

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

Parameters

object
Object expression that evaluates to a control or Form object.
button
Integer that identifies the button that was released to cause the event.
shift
Returns an integer that corresponds to the state of the SHIFT, CTRL, and ALT keys when the button specified in the button parameter is pressed or released.
x, y
Returns a number that specifies the current location of the pointer of the mouse device.

Remarks

Use a MouseUp event procedure to specify actions that will occur when a user presses or releases a button of a mouse device. Unlike the Click and DblClick events, MouseUp events enable you to distinguish between the left and right buttons on a mouse device.

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 Not supported.

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.

You can use a MouseMove event procedure to respond to an event caused by moving the mouse device. The button parameter for MouseUp differs from the button parameter used for MouseMove. For MouseUp, the button parameter indicates exactly one button per event, whereas for MouseMove, the button parameter indicates the current state of all buttons.