LargeChange, SmallChange Properties Example

Microsoft Office Outlook 2003

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:

  • A Label named Label1
  • A TextBox named TextBox1 that is bound to the custom number field named ScrollBarSmallChange
  • A Label named Label2
  • A TextBox named TextBox2 that is bound to the custom number field named ScrollBarLargeChange.
  • A ScrollBar named ScrollBar1 that is bound to the custom number field named ScrollBarValue.
  • A Label named Label3.
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