Hey guys,
I'm trying to create an app. /w a function that allows a user to click on either of two scrollbars on screen and see the other one move with the right conversion.
For example, one bar would be labeled as Fahrenheit and the other as Celsius. If as user clicks and scrolls one of them. The other will change with the appropriate conversion taking place.
So if someone scrolled the Fahrenheit bar to 32 then the Celsius bar would change in real time to 0.
These numbers would be displayed in labels of course.
However, I know this code can be done with a simple function returning the right number for both scrollbar values depending on whats clicked.
This is what I have so far, however it does nothing except show the ValueChanged in the labels.
CODE
Public Class Form1
Private Function GetNumber(ByVal intNum As Integer, ByVal scaleStr As String) As Integer
Dim intAnswer As Integer
If scaleStr = "F" Then
intAnswer = (5 / 9) * (intNum - 32)
Else
intAnswer = (9 / 5) * intNum + 32
End If
Return intAnswer
End Function
Private Sub FarenheitHScrollBar_ValueChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles FarenheitHScrollBar.ValueChanged
Dim farenInt As Integer
farenInt = GetNumber(FarenheitHScrollBar.Value, "F")
FarenLabel.Text = farenInt.ToString
End Sub
Private Sub CelsiusHScrollBar_ValueChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles CelsiusHScrollBar.ValueChanged
Dim celsInt As Integer
celsInt = GetNumber(CelsiusHScrollBar.Value, "C")
CelsLabel.Text = celsInt.ToString
End Sub
End Class
Any help to correct this would be greatly appreciated.
This post has been edited by Slayer6234: 22 Apr, 2008 - 10:21 AM