Visual Basic offers many controls that can be used to make apparently complex problems easy to solve with a simple solution. The Scroll Bar is one such tool that provides a sliding scale of numbers that can then be used to calculate another value. A simple example is shown below.
Problem
A program is needed to convert temperature in degrees celcius to degrees farenheit between 0 degrees C and 100 degrees C.

| Output | The temperature in degrees Farenheit |
| Input | The temperature in degrees Celcius |
| Processes | Convert the value for Celcius to Farenheit using rule F = C* 9 / 5 + 32 |
Form and Controls
Controls
This applications needs six Labels, one CommandButton and one Horizontal ScrollBar. The properties and settings for one of each control is shown below.
| Object | Property | Setting |
| Horizontal Scroll Bar | Name | HScrDegreesC |
| max | 100 | |
| min | 0 | |
| Comamnd Button | Caption | End |
| Name | CmdEnd | |
| Label | Caption | Temperature Converter |
| Name | LblHeading | |
| BackStyle | 0-Transparent | |
| Font | Ariel Black | |
| ForeColor | (red) | |
| Label | Caption | (blank) |
| Name | LblCelcius | |
| BackStyle | 0-Transparent | |
| Font | Ariel Black | |
| ForeColor | Black |
Pseudocode
GET Celcius Temperature (current Scroll Bar
Value)
WRITE Celcius
SET Farenheit TO Celcius * 9 / 5 + 32
WRITE
Farenheit
Code
Private Sub HScrDegreesC_Change()
' Read in the temperature from the scroll bar value and display in a label
LblCelcius.Text = HScrDegreesC.Value
'Calculate the Farenheight value and display the result in a label
LblFarenheit.Text = HScrDegreesC.Value * 9 / 5 + 32
End Sub
The above program will take the current value for the scroll bar and place it in the Label for the Celcius value. It will also apply the rule to that value and determine the Farenheit equivalent. This will be places in the Label for the Farenheit value.
As the scroll bar is moved, the labes for Celcuis and Farenheit are automatically updated.
Author: Mike Leishman
Last Modified 8 June 1998