As with scroll bars, track bars have two events—Scroll and ValueChanged. And—also as with scroll bars—you can get the current value of the track bar with the Value property. Here's how the TrackBars example, which you can see at work in Figure 8.3, works; all we do there is to display the current value of the track bar in a text box in a Scroll event handler:
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles TrackBar1.Scroll
TextBox1.Text = "Track bar value: " & TrackBar1.Value
End Sub
You can see the results of this code in Figure 8.3.