LargeChange, SmallChange Properties Example

The following example demonstrates the LargeChange and SmallChange properties when used with a stand-alone ScrollBar. The user can set the LargeChange and SmallChange values to any integer in the range of 0 to 100. This example also uses the MaxLength property to restrict the number of characters entered for the LargeChange and SmallChange values.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

Sub Item_Open()
    Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")
    Set ScrollBar1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ScrollBar1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set Label2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label2")
    Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")
    Set Label3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label3")

    ScrollBar1.Min = -1000
    ScrollBar1.Max = 1000
    
    Label1.Caption = "SmallChange 0 to 100"
    ScrollBar1.SmallChange = 1
    TextBox1.Text = ScrollBar1.SmallChange
    TextBox1.MaxLength = 3
    
    Label2.Caption = "LargeChange 0 to 100"
    ScrollBar1.LargeChange = 100
    TextBox2.Text = ScrollBar1.LargeChange
    TextBox2.MaxLength = 3
    
    ScrollBar1.Value = 0
    Label3.Caption = ScrollBar1.Value
End Sub

Sub Item_CustomPropertyChange(byval pname)
    Set ScrollBar1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ScrollBar1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")
    Set Label3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label3")

    If pname = "ScrollBarMin" Then

        If IsNumeric(TextBox1.Text) Then
            TempNum = CInt(TextBox1.Text)
            If TempNum >= 0 And TempNum <= 100 Then
                ScrollBar1.SmallChange = TempNum
            Else
                TextBox1.Text = ScrollBar1.SmallChange
            End If
        Else
            TextBox1.Text = ScrollBar1.SmallChange
        End If

    ElseIf pname = "ScrollBarMax" Then

        If IsNumeric(TextBox2.Text) Then
            TempNum = CInt(TextBox2.Text)
            If TempNum >= 0 And TempNum <= 100 Then
                ScrollBar1.LargeChange = TempNum
            Else
                TextBox2.Text = ScrollBar1.LargeChange
            End If
        Else
            TextBox2.Text = ScrollBar1.LargeChange
        End If

    ElseIf pname = "ScrollBarValue" Then

        Label3.Caption = ScrollBar1.Value
    End If
End Sub