r = rR * 255: g = rG * 255: b = rB * 255 
End Sub 

Private Function Maximum(rR As Single, rG As Single, rB As Single) As Single 
    If (rR &gt; rG) Then 
        If (rR &gt; rB) Then 
            Maximum = rR 
        Else 
            Maximum = rB 
        End If 
    Else 
        If (rB &gt; rG) Then 
            Maximum = rB 
        Else 
            Maximum = rG 
        End If 
    End If 
End Function 

Private Function Minimum(rR As Single, rG As Single, rB As Single) As Single 
    If (rR &lt; r