Results 1 to 6 of 6

Thread: Slider examples

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2022
    Posts
    2

    Slider examples

    Can anyone point me toward some SUPER SIMPLE examples using the slider in VB6? I mean: VERY SIMPLE, beginner stuff....... I am not 100% new to the world of BASIC, but am super rusty!

  2. #2
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,708

    Re: Slider examples

    There's not much to it... you put it on your form, set the options in the property pages for orientation etc, you can set the min/max there or by code, and .Value is where it is in between min/max, you can set it or retrieve it.

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Slider examples

    I know people hate hearing it, but the documentation really is your friend.

  4. #4
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    370

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: Slider examples

    Quote Originally Posted by dilettante View Post
    I know people hate hearing it, but the documentation really is your friend.
    As in (From MSDN):

    Using the Slider Control

    Name:  1.JPG
Views: 526
Size:  28.2 KB







    A Slider control consists of a scale, defined by the Min and Max properties, and a "thumb," which the end user can manipulate using the mouse or arrow keys. At run time, the Min and Max properties can be dynamically reset to reflect a new range of values. The Value property returns the current position of the thumb. Using events such as the MouseDown and MouseUp events, the Slider control can be used to graphically select a range of values.
    Possible Uses


    • To set the value of a point on a graph.
    • To select a range of numbers to be passed into an array.
    • To resize a form, field, or other graphic object.

    TickStyle and TickFrequency Properties

    The Slider control consists of two parts: the thumb and the ticks, as shown below:

    Name:  2.JPG
Views: 550
Size:  10.2 KB


    The appearance of the control depends on the TickStyle property. In brief, the ticks can appear along the bottom of the control, as shown above (the default style), along the top, along both top and bottom, or not at all.
    In addition to the placement of the ticks, you can also program how many ticks appear on the control by setting the TickFrequency property. This property, in combination with the Min and Max properties, determines how many ticks will appear on the control. For example, if the Min property is set to 0, the Max to 100, and the TickFrequency to 5, there will be one tick for every five increments, for a total of 21. If you reset the Min and Max properties at run time, the number of ticks can be determined by using the GetNumTicks method, which returns the number of ticks on the control.
    Set the Min, Max Properties at Design Time or Run Time

    The Min and Max properties determine the upper and lower limits of a Slider control, and you can set these properties at either design time or run time. At design time, right-click on the control and click Properties to display the Property Pages dialog box, as shown below:

    At run time, you can reset the Min and Max settings to accommodate different ranges. For example, if you are using the Slider to change values in a database, you can use the same control and bind it to different fields depending on what table the user is editing.
    SmallChange and LargeChange Properties

    The SmallChange and LargeChange properties determine how the Slider control will increment or decrement when the user clicks it. The SmallChange property specifies how many ticks the thumb will move when the user presses the left or right arrow keys. The LargeChange property specifies how many ticks the thumb will move when the user clicks the control or when the user presses the PAGEUP or PAGEDOWN keys.
    Selecting Ranges

    If the SelectRange property is set to True, the Slider control changes its appearance, as shown below:

    To select a range of values, you must use the SelStart and SelLength properties. For a detailed example of this, see "Slider Scenario 2: Select a Range of Values with the Slider" in this chapter
    Last edited by SamOscarBrown; Aug 22nd, 2022 at 08:36 AM.
    Sam I am (as well as Confused at times).

  6. #6
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: Slider examples

    place a slider control and a picturebox on a form.
    Don't change any property of the slider control
    Make the picturebox height and width each = 2000

    put this code in the form:
    Code:
    Option Explicit
    Dim iIncrement As Integer
    Private Sub Form_Load()
        iIncrement = 100
    End Sub
    
    
    Private Sub Slider1_Scroll()
        Picture1.Width = 2000 + (iIncrement * Slider1.Value)
        Picture1.Height = 2000 + (iIncrement * Slider1.Value)
    End Sub
    Run the program...move the slide thumb with the mouse and watch the picturebox
    Sam I am (as well as Confused at times).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width