# R – purpose of dividing saturation / 50 and hue / 50

vb.netwinforms

i am controlling the hue and saturation of the backcolor of the form with scrollbars:

``````Private Sub tbHUE_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbHue.Scroll
Dim r, g, b As Integer
HSVtoRGB(r, g, b, tbHue.Value, tbSaturation.Value / 50, 255)
Form1.BackColor = Color.FromArgb(r, g, b)
Label1.Text = tbHue.Value

End Sub
Private Sub tbsaturation_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbSaturation.Scroll
Dim r, g, b As Integer
HSVtoRGB(r, g, b, tbHue.Value, tbSaturation.Value / 50, 255)
Form1.BackColor = Color.FromArgb(r, g, b)
Label2.Text = tbSaturation.Value
End Sub
``````

i would like to know what is the purpose of dividing by 50?

#### Best Solution

If you're referring to this question: implementing a trackbar that will change background color of form, the HSVtoRGB procedure expects:

• a saturation value between 0.0 and 1.0
• a value value between 0.0 and 1.0
• a hue value between 0 and 360

This is in-line with the intent of the algorithm, as it points to the wikipedia version as its reference, at http://www.xtremevbtalk.com/showthread.php?t=302304. I didn't proofread the implementation to check for correctness though.

Dividing the saturation value you get from the tbSaturation textbox by 50 allows you to interpret values between 0 and 50 entered by the user. You might actually want to divide by 100 instead to allow a 0-100 range.