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
- Double click the horizontal scroll bar and attach the following code:
Private Sub hsbTemp_Change()
lblFah.Caption = hsbTemp.Value
lblCelsius.Caption = Int((hsbTemp.Value - 32) * 0.56)
End SubThis 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.
- Double click the cmdExit button and attach the following code:
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.
![]() |
|



