Delay Property

Applies To

ScrollBar control, SpinButton control.

Description

Specifies the delay for the SpinUp, SpinDown, and Change events on a SpinButton or ScrollBar.

Syntax

object.Delay [= Long]

The Delay property syntax has these parts:

Part

Description

object

Required. A valid object.

Long

Optional. The delay, in milliseconds, between events.


Remarks

The Delay property affects the amount of time between consecutive SpinUp, SpinDown, and Change events generated when the user clicks and holds down a button on a SpinButton or ScrollBar. The first event occurs immediately. The delay to the second occurrence of the event is five times the value of the specified Delay. This initial lag makes it easy to generate a single event rather than a stream of events.

After the initial lag, the interval between events is the value specified for Delay.

The default value of Delay is 50 milliseconds. This means the object initiates the first event after 250 milliseconds (5 times the specified value) and initiates each subsequent event after 50 milliseconds.

See Also

Change event, SpinDown, SpinUp events.

Example

The following example demonstrates the time interval between successive Change, SpinUp, and SpinDown events that occur when a user holds down the mouse button to change the value of a SpinButton or ScrollBar.

In this example, the user chooses a delay setting, then clicks and holds down either side of a SpinButton. The SpinUp and SpinDown events are recorded in a ListBox as they are initiated.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • A SpinButton named SpinButton1.
  • Two OptionButton controls named OptionButton1 and OptionButton2.
  • A ListBox named ListBox1.
    Dim EventCount As Long
    
    Private Sub ResetControl()
        ListBox1.Clear
        EventCount = 0
        SpinButton1.Value = 5000
    End Sub
    
    Private Sub UserForm_Initialize()
        SpinButton1.Min = 0
        SpinButton1.Max = 10000
        ResetControl
        
        SpinButton1.Delay = 50
        OptionButton1.Caption = "50 millisecond delay"
        OptionButton2.Caption = "250 millisecond delay"
            
        OptionButton1.Value = True
    End Sub
    
    Private Sub OptionButton1_Click()
        SpinButton1.Delay = 50
        ResetControl
    End Sub
    
    Private Sub OptionButton2_Click()
        SpinButton1.Delay = 250
        ResetControl
    End Sub
    
    Private Sub SpinButton1_SpinDown()
        EventCount = EventCount + 1
        ListBox1.AddItem EventCount
    End Sub
    
    Private Sub SpinButton1_SpinUp()
        EventCount = EventCount + 1
        ListBox1.AddItem EventCount
    End Sub