h &lt; 2) Then 
                rB = Min 
                rR = rB - (h - 2) * (Max - Min) 
            Else 
                rR = Min 
                rB = (h - 2) * (Max - Min) + rR 
            End If 
        Else 
            rB = Max 
            If (h &lt; 4) Then 
                rR = Min 
                rG = rR - (h - 4) * (Max - Min) 
            Else 
                rG = Min 
                rR = (h - 4) * (Max - Min) + rG 
            End If         
        End If             
    End If 
    