UpDown Control
Provides a spin button for incrementing/decrementing numeric values, supporting buddy control synchronization, wrapping, and hexadecimal display.
Enumerations
UdnOrientationConstants
Control orientation constants.
| Constant | Value | Description |
|---|---|---|
| UdnOrientationVertical | 0 | Vertical orientation |
| UdnOrientationHorizontal | 1 | Horizontal orientation |
UdnNumberStyleConstants
Number display style constants.
| Constant | Value | Description |
|---|---|---|
| UdnNumberStyleDecimal | 0 | Decimal |
| UdnNumberStyleHexadecimal | 1 | Hexadecimal |
Properties
Name
Public Property Get Name() As StringReturns the name used to identify the object in code.
Tag
Public Property Get Tag() As String
Public Property Let Tag(ByVal Value As String)Stores extra data needed by the program.
Parent
Public Property Get Parent() As ObjectReturns the object that contains this object.
Container
Public Property Get Container() As Object
Public Property Set Container(ByVal Value As Object)Returns/sets the container of the object.
Left
Public Property Get Left() As Single
Public Property Let Left(ByVal Value As Single)Returns/sets the distance between the left edge of the object and the left edge of its container.
Top
Public Property Get Top() As Single
Public Property Let Top(ByVal Value As Single)Returns/sets the distance between the top edge of the object and the top edge of its container.
Width
Public Property Get Width() As Single
Public Property Let Width(ByVal Value As Single)Returns/sets the width of the object.
Height
Public Property Get Height() As Single
Public Property Let Height(ByVal Value As Single)Returns/sets the height of the object.
Visible
Public Property Get Visible() As Boolean
Public Property Let Visible(ByVal Value As Boolean)Returns/sets whether the object is visible.
ToolTipText
Public Property Get ToolTipText() As String
Public Property Let ToolTipText(ByVal Value As String)Returns/sets the tooltip text displayed when the mouse hovers.
WhatsThisHelpID
Public Property Get WhatsThisHelpID() As Long
Public Property Let WhatsThisHelpID(ByVal Value As Long)Returns/sets the associated context help ID.
DragIcon
Public Property Get DragIcon() As IPictureDisp
Public Property Let DragIcon(ByVal Value As IPictureDisp)
Public Property Set DragIcon(ByVal Value As IPictureDisp)Returns/sets the icon displayed during a drag-and-drop operation.
DragMode
Public Property Get DragMode() As Integer
Public Property Let DragMode(ByVal Value As Integer)Returns/sets the drag mode.
hWnd
Public Property Get hWnd() As LongPtrReturns the control handle.
hWndUserControl
Public Property Get hWndUserControl() As LongPtrReturns the UserControl handle.
VisualStyles
Public Property Get VisualStyles() As Boolean
Public Property Let VisualStyles(ByVal Value As Boolean)Returns/sets whether visual styles are enabled. Requires comctl32.dll version 6.0 or later.
Enabled
Public Property Get Enabled() As Boolean
Public Property Let Enabled(ByVal Value As Boolean)Returns/sets whether the object can respond to user events.
OLEDropMode
Public Property Get OLEDropMode() As OLEDropModeConstants
Public Property Let OLEDropMode(ByVal Value As OLEDropModeConstants)Returns/sets whether the object can act as an OLE drop target.
MousePointer
Public Property Get MousePointer() As CCMousePointerConstants
Public Property Let MousePointer(ByVal Value As CCMousePointerConstants)Returns/sets the type of mouse pointer displayed when hovering. See common enumerations.
MouseIcon
Public Property Get MouseIcon() As IPictureDisp
Public Property Let MouseIcon(ByVal Value As IPictureDisp)
Public Property Set MouseIcon(ByVal Value As IPictureDisp)Returns/sets the custom mouse icon.
MouseTrack
Public Property Get MouseTrack() As Boolean
Public Property Let MouseTrack(ByVal Value As Boolean)Returns/sets whether events are fired when the mouse enters or leaves the control.
RightToLeft
Public Property Get RightToLeft() As Boolean
Public Property Let RightToLeft(ByVal Value As Boolean)Returns/sets the right-to-left display direction.
RightToLeftLayout
Public Property Get RightToLeftLayout() As Boolean
Public Property Let RightToLeftLayout(ByVal Value As Boolean)Returns/sets the right-to-left layout.
RightToLeftMode
Public Property Get RightToLeftMode() As CCRightToLeftModeConstants
Public Property Let RightToLeftMode(ByVal Value As CCRightToLeftModeConstants)Returns/sets the right-to-left mode. See common enumerations.
BuddyControl
Public Property Get BuddyControl() As Variant
Public Property Let BuddyControl(ByVal Value As Variant)
Public Property Set BuddyControl(ByVal Value As Variant)Returns/sets the associated buddy control.
BuddyProperty
Public Property Get BuddyProperty() As String
Public Property Let BuddyProperty(ByVal Value As String)Returns/sets the property name of the buddy control used for data synchronization.
SyncBuddy
Public Property Get SyncBuddy() As Boolean
Public Property Let SyncBuddy(ByVal Value As Boolean)Returns/sets whether to automatically synchronize the value with the buddy control.
Min
Public Property Get Min() As Long
Public Property Let Min(ByVal Value As Long)Returns/sets the minimum value.
Max
Public Property Get Max() As Long
Public Property Let Max(ByVal Value As Long)Returns/sets the maximum value.
Value
Public Property Get Value() As Long
Public Property Let Value(ByVal Value As Long)Returns/sets the current value.
Increment
Public Property Get Increment() As Long
Public Property Let Increment(ByVal Value As Long)Returns/sets the increment/decrement amount per click.
Wrap
Public Property Get Wrap() As Boolean
Public Property Let Wrap(ByVal Value As Boolean)Returns/sets whether the value wraps. When True, exceeding the maximum value wraps to the minimum and vice versa.
HotTracking
Public Property Get HotTracking() As Boolean
Public Property Let HotTracking(ByVal Value As Boolean)Returns/sets whether hot tracking is enabled.
Orientation
Public Property Get Orientation() As UdnOrientationConstants
Public Property Let Orientation(ByVal Value As UdnOrientationConstants)Returns/sets the control orientation.
ThousandsSeparator
Public Property Get ThousandsSeparator() As Boolean
Public Property Let ThousandsSeparator(ByVal Value As Boolean)Returns/sets whether to display the thousands separator.
NumberStyle
Public Property Get NumberStyle() As UdnNumberStyleConstants
Public Property Let NumberStyle(ByVal Value As UdnNumberStyleConstants)Returns/sets the number display style.
Methods
OLEDrag
Public Sub OLEDrag()Initiates an OLE drag-and-drop operation.
Drag
Public Sub Drag(Optional ByRef Action As Variant)Starts, ends, or cancels a drag operation.
ZOrder
Public Sub ZOrder(Optional ByRef Position As Variant)Sets the Z-order.
Refresh
Public Sub Refresh()Forces a complete repaint of the object.
SyncFromBuddy
Public Sub SyncFromBuddy()Synchronizes the value from the buddy control to the UpDown control.
Events
DownClick
Public Event DownClick()Fired when the down/left button is clicked.
UpClick
Public Event UpClick()Fired when the up/right button is clicked.
BeforeChange
Public Event BeforeChange(ByVal Value As Long, ByRef Delta As Long)Fired before the value is about to change. Value is the current value, Delta is the expected change amount; modifying Delta controls the actual change.
Change
Public Event Change()Fired after the value changes.
MouseDown
Public Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)Fired when a mouse button is pressed.
MouseMove
Public Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)Fired when the mouse is moved.
MouseUp
Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)Fired when a mouse button is released.
MouseEnter
Public Event MouseEnter()Fired when the mouse enters the control area.
MouseLeave
Public Event MouseLeave()Fired when the mouse leaves the control area.
OLECompleteDrag
Public Event OLECompleteDrag(Effect As Long)Fired when an OLE drag-and-drop operation completes.
OLEDragDrop
Public Event OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)Fired when data is dropped via an OLE drag-and-drop operation.
OLEDragOver
Public Event OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)Fired when the mouse hovers during an OLE drag-and-drop operation.
OLEGiveFeedback
Public Event OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)Fired when an OLE drag-and-drop operation gives feedback.
OLESetData
Public Event OLESetData(Data As DataObject, DataFormat As Integer)Fired when an OLE drag-and-drop operation sets data.
OLEStartDrag
Public Event OLEStartDrag(Data As DataObject, AllowedEffects As Long)Fired when an OLE drag-and-drop operation starts.
Code Examples
Basic Usage
' Set up the UpDown control
With UpDown1
.Min = 0
.Max = 100
.Value = 50
.Increment = 5
.Wrap = True
Set .BuddyControl = Text1
.BuddyProperty = "Text"
.SyncBuddy = True
End With
' Limit value change range
Private Sub UpDown1_BeforeChange(ByVal Value As Long, ByRef Delta As Long)
If Value + Delta > 100 Then Delta = 0
End Sub
' Respond to value change
Private Sub UpDown1_Change()
Debug.Print "Current value: " & UpDown1.Value
End Sub