Take advantage the Slider control’s Select Range mode

The Slider control has a capability that you might ignore: you can assign its SelectRange property to True to enter Select Range mode, during which the user can use the Slider to select a range instead of a single value. When in Select Range mode, however, it’s up to you to manage the SelStart and SelLength properties, and you have to ensure that SelStart is always positive.

The following code sample shows how you can enter Select Range mode when the user moves the mouse while pressing the Shift key:

' Enter Select Range mode when the user moves the mouse while keeping the SHIFT ' key pressedPrivate Sub Slider1_MouseDown(Button As Integer, Shift As Integer, x As Single, _    y As Single)    ' if the shift key is being pressed, enter Select Range mode    If Shift = vbShiftMask Then        Slider1.SelectRange = True        Slider1.SelLength = 0        ' remember current position in Tag property        Slider1.Tag = Slider1.Value    Else        Slider1.SelectRange = False    End IfEnd Sub' modify the selected range when the user moves the Slider's indicatorPrivate Sub Slider1_Scroll()    If Slider1.SelectRange Then        ' get initial value        Dim StartSelection As Single        StartSelection = Val(Slider1.Tag)        ' if the indicator is being moved in SelectRange mode, you must        ' discern between two cases        If Slider1.Value > StartSelection Then            Slider1.SelStart = StartSelection            Slider1.SelLength = Slider1.Value - StartSelection        Else            Slider1.SelStart = Slider1.Value            Slider1.SelLength = StartSelection - Slider1.Value        End If    End IfEnd Sub

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

technology leadership

Why the World Needs More Technology Leadership

As a fact, technology has touched every single aspect of our lives. And there are some technology giants in today’s world which have been frequently opined to have a strong influence on recent overall technological influence. Moreover, those tech giants have popular technology leaders leading the companies toward achieving greatness.

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job