Scroll, Change Events, TrackValue Property (Slider, Scroll)

Purpose

Occurs when you move the slider on a Slider control or the scroll box on a Scroll control, either by clicking on the control or using keyboard commands.

Syntax

Sub object_Scroll( [index%] )

Sub object_Change( [index%])

Scroll.TrackValue [ = value ]

object:Scroll, Slider Ocx
index%:iexp, index when control is part of control array
value:iexp

Description

The Change event indicates the contents of a control have changed. In fact, the Change event is triggered when the Value property has changed. The event is triggered after the Scroll or Slider control has changed. By contrast, the Scroll event is continually triggered during the dragging. During the Scroll event the value of the scroll box can be obtained using the TrackValue property. The TrackValue property is a Scroll Ocx property valid only in the Scroll event sub, and is not shared with the Slider control. The current value for the Slider is simply obtained using Value.

A Scroll event is always followed by a Change event.

Example

OpenW Center # 1, , , 400, 200

Me.BackColor = colBtnFace

Ocx Scroll sc1 = "", 10, 10, 370, 20

Ocx Label lb0 = "Value:", 10, 50, 100, 20

.Alignment = basRightJustify

Ocx Label lb1 = Str(sc1.Value), 120, 50, 50, 20

Ocx Slider sl1 = "", 10, 90, 370, 20

Ocx Label lb01 = "Value:", 10, 130, 100, 20

.Alignment = basRightJustify

Ocx Label lb2 = Str(sl1.Value), 120, 130, 50, 20

Do

Sleep

Loop Until Me Is Nothing

 

Sub sc1_Scroll()

lb1.Text = Str$(sc1.TrackValue)

EndSub

 

Sub sc1_Change()

lb1.Text = Str$(sc1.Value)

EndSub

 

Sub sl1_Scroll

lb2.Text = Str$(sl1.Value)

EndSub

 

Sub sl1_Change

lb2.Text = Str$(sl1.Value)

EndSub

Remarks

The Scroll and Change events can be compared to the Form Scrollbars as follows:

_HScrolling, _VScrolling events_Scroll event

HScTrack, VScTrack propertiesTrackValue property

_HScroll, _VScroll events _Change event

HScPos, VScPos properties Value property (Default)

See Also

Scroll, Slider

{Created by Sjouke Hamstra; Last updated: 22/10/2014 by James Gaite}