Let's look again at our Fahrenheit to Celsius converter.  Instead of getting the user to type in a temperature, we are going to give them a horizontal scroll bar to use.

Start a new project and save it as tempconverter2.

Design the Interface

Set up the interface like this: 

Use labels for both temperatures - do not use a text box. Name them lblFah and lblCelsius, set properties as for the previous project.

Set properties for the horizontal scroll bar as below:

Name hsbTemp
Max 450
Min 100

Write the Code

Private Sub hsbTemp_Change()
    lblFah.Caption = hsbTemp.Value
    lblCelsius.Caption = Int((hsbTemp.Value - 32) * 0.56)
End Sub

This code sets the caption for the Fahrenheit label to be the value of the scroll bar, and then converts it to celsius for the other label.

Private Sub cmdExit_Click()
     Unload Me
End Sub


Test Your Program

Test your program.  After eliminating any errors, look to see how you could improve its usability.  Perhaps a label explaining how to use the scroll bar would be helplful.

A scientist wants to use your temperature converter for science experiments but she says that the slider does not cover a wide enough temperature range and she also needs the converted values to 1 decimal place.

Modify the program so that the Fahrenheit ranges go from -100 to 600 degrees and the converted values have 1 decimal place. 

To format the Celsius caption so that it has one decimal point, use this line:

lblCelsius.Caption = Format((hsbTemp.Value - 32) * 0.56, "0.0")

"0.0"  gives the format form lblCelsius.caption

How would you modify it to have 2 decimal places?