HSV_HfromRGB example for Visual Basic

'Takes an RGB, displays the RGB components, and displays the HSV components

Private Sub RGBtoHSV(cr As OLE_COLOR)
Dim red As Integer
Dim green As Integer
Dim blue As Integer
Dim h As Integer
Dim s As Integer
Dim v As Integer

red = cr And &HFF
green = (cr \ &H100) And &HFF
blue = cr \ &H10000

h = LEAD1.HSV_HfromRGB(cr)
s = LEAD1.HSV_SfromRGB(cr)
v = LEAD1.HSV_VfromRGB(cr)

MsgBox "RGB (" & red & "," & green & "," & blue & ") is HSV(" & h & "," & s & "," & v & ")"
End Sub