NewSlider

Description

Adds a slider control to a form

Syntax

[Set oCtl =] oFrm.NewSlider

( Name, Left, Top, Width, Height, Min, Max, [Value], [Container] )

Parameters

Part

Description

Set oCtl =

(optional) Store a reference to the new control in the variable oCtl. This variable can be used to access the control's properties and methods

oFrm

A reference to a form object (see the NewForm method)

Name

The name of the control. It must be unique within the form and may not be empty or start with an asterisk (*)

Left

See the list of properties below

Top

See the list of properties below

Width

See the list of properties below

Height

See the list of properties below

Min

See the list of properties below

Max

See the list of properties below

Value

(optional) See the list of properties below

Container

(optional) The name of an existing frame control that will act as container for the slider. If unspecified or an empty string, the Form itself will be the container. Please note that the Left and Top properties are relative to the container's left and top edges

Properties, Methods and Events

Property

Description

BorderStyle

0

No border (default)

1

Fixed single

Enabled

(boolean) Determines if the control can respond to user-generated events

Height

The height of the control in twips

LargeChange

The number of ticks the slider will move when you press the PageUp/Down keys, or click the mouse to the left or right of the slider. The default is 5

Left

The distance from the left edge of the specified container in twips

Max

The maximum value of the range (default 10, maximum 32767)

Min

The minimum value of the range (default 0, maximum 32767)

Orientation

0

Horizontal (default)

1

Vertical

Parent

(read-only) Returns the parent form, object or collection. You can use the parent property to access the properties and methods of an object's parent

SmallChange

The number of ticks the slider will move when you press the left or right arrow keys. The default is 1

TabStop

(boolean) Determines whether the TAB key can be used to move the focus

Tag

(reserved) Used internally to store the user-defined controlname

TextPosition

0

ToolTipText will be displayed above a horizontal slider or to the left of a vertical slider

1

ToolTipText will be displayed below a horizontal slider or to the right of a vertical slider

Tickfrequency

The frequency of tick marks in relation to the range. If the range is 100 and the TickFrequency is set to 2, there will be one tick for every 2 increments

TickStyle

Determines the style (or positioning) of the tick marks. The default is 0

0

Along the bottom for horizontal sliders; to the right for vertical sliders

1

Along the top for horizontal sliders; to the left for vertical sliders

2

Combination of styles 0 and 1

3

No tick marks are displayed

ToolTipText

Explanatory text that appears in a small rectangle below the object when you pause the mouse pointer (hover) over it for about one second

Top

The distance from the top edge of the specified container in twips

Value

(integer) Sets the current position of the slider. Value must always be between the Min and Max properties, inclusive

Visible

(boolean) Determines whether the control is visible or hidden

Width

The width of the control in twips

Method

Description

GetNumTicks

Returns the number of ticks between the Min and Max properties

Move

Parameters: left [, top [, width [, height ]]]

Only the left argument is required. However, to specify any other arguments, you must specify all arguments that appear in the syntax before the argument you want to specify. For example, you can't specify width without specifying left and top. Any trailing arguments that are unspecified remain unchanged

Refresh

Forces a complete repaint of a control

SetFocus

Moves the focus to the specified control

Event

Description

Event raised

Change

Occurs when the slider is moved with either the left mouse button, the keyboard or through code

Controlname

To be able to handle events you need to operate a form in callback mode.
This subject is described in the following topics:
Callback forms, ClickHandler

Example

Option Explicit

Const vbModal = 1

Dim oDlg, oFrm, oCtl

'Create the WshDialog.Kit object and store a reference in oDlg
Set oDlg = Wscript.CreateObject("WshDialog.Kit", "oDlg_")

'Add a new form and store a reference to it in the variable oFrm
Set oFrm = oDlg.NewForm("Sample")

'Add a slider control and store a reference in the variable oCtl
Set oCtl = oFrm.NewSlider("SLIDER", 150, 150, 4000, 300, 0, 100, 0)

'Change some properties and move the position to 25
oCtl.TickFrequency = 10
oCtl.LargeChange = 10
oCtl.Value = 25

'Add an OK button and set it's Default property
Set oCtl = oFrm.NewButton("OK", 4250, 100, 1000, 375, "&OK")
oCtl.Default = True

'Automatically size the form and show it (modally)
oFrm.Autosize
oFrm.Show vbModal

'Show the slider's value
MsgBox "The slider value is : " & oFrm.Ctl("SLIDER").Value