
Next, we will write a program that uses a scroll bar to select the radius of a circle. Whenever a value is selected on the scroll bar, we will display the circumference and area of the circle. Start a new windows application named Circle. build the form as shown below:
Add a VerticalScrollBar
and name it VSBRadius.
Add labels as shown in the illustration: LblRadiusHeader with text= "Select the radius:"; LblRadius with text="0"; LblCircumferenceHeader with text="Circumference"; LblCircumference with text="0"; LblAreaHeader with text="Area"; and LblArea with text="0"
Write the code as shown below:
Private Sub VSBRadius_Scroll(ByVal sender As System.Object, ByVal e As_
System.Windows.Forms.ScrollEventArgs) Handles VSBRadius.Scroll
Me.LblRadius.Text = Me.VSBRadius.Value
Me.LblCircumference.Text = 2 * System.Math.PI * Me.VSBRadius.Value
Me.LblArea.Text = System.Math.PI * System.Math.Pow(Me.VSBRadius.Value, 2)
End Sub