TickFreqency Property Example

This example matches a TextBox control's width to that of a Slider control. While the Slider control's Value property is above a certain value, the TextBox control's width matches the Slider control's value. The TickFrequency depends on the value of the Slider control's Max property. To try the example, place a Slider and a TextBox control on a form and paste the code into the form's Declarations section. Run the example and click the slider several times.

Private Sub Form_Load()
   Text1.Width = 4500 ' Set a minimum width for the TextBox.
   Slider1.Left = Text1.Left ' Align the Slider to the TextBox.
   ' Match the width of the Slider to the TextBox.
   Slider1.Max = Text1.Width
   ' Place the Slider a little below the Textbox.
   Slider1.Top = Text1.Top + Text1.Height + 50
   ' Set TickFrequency to a fraction of the Max value.
   Slider1.TickFrequency = Slider1.Max * 0.1
   ' Set LargeChange and SmallChange value to a fraction of Max.
   Slider1.LargeChange = Slider1.Max * 0.1
   Slider1.SmallChange = Slider1.Max * 0.01
End Sub

Private Sub Slider1_Change()
   ' If the slider is under 1/3 the size of the textbox, no change.
   ' Else, match the width of the textbox to the Slider's value.
   If Slider1.Value > Slider1.Max / 3 Then
      Text1.Width = Slider1.Value
   End If
End Sub