circle
Circle

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 VerticalScrollBarand 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

Experiment: Use your imagination! Write another program that uses a scroll bar to get the values for a calculation.
INDEX, The Code View, Selecting code from list, Events, Arguments, Concatenation, Sender, Scroll Bars, Decimal Values on Scroll Bar, Picture Boxes: the Seasons, Comments, Printing, Closing
Next lesson: Functions in Visual Basic

Copyright © Zebra0.com
All rights reserved worldwide.

 
 

Scroll Bars