請教各位大大
小弟目前遇到一個問題
小弟欲在if內寫入判斷式,但輸出的值都與小弟所需求的不同
這地方卡了很久了,是否方便請大大幫忙看一下那裡有問題呢?
感謝
公式:
if max=min , 值=0
if max=R and G >=B , 值= 60x ((G-B)/max=min)+0
if max=R and G < B , 值= 60x ((G-B)/max=min)+360
if max=G , 值= 60x ((B-R)/max=min)+120
if max=B , 值= 60x ((R-G)/max=min)+240
VBA寫入:
Dim Rs, Gs, Bs, Cmax, Cmin, Delta, Hx As Single
Cmax = Application.Max(Rs, Gs, Bs)
Cmin = Application.Min(Rs, Gs, Bs)
Delta = Cmax - Cmin
If Delta = 0 Then
Hx = 0
ElseIf Rs > Bs Or Gs > Bs Then
Hx = (60 * ((Gs - Bs) / Delta)) + 0
ElseIf Rs < Bs Or Gs < Bs Then
Hx = (60 * ((Gs - Bs) / Delta)) + 360
ElseIf Cmax = Gs Then
Hx = (60 * ((Bs - Rs) / Delta)) + 120
ElseIf Cmax = Bs Then
Hx = (60 * ((Rs - Gs) / Delta)) + 240
End If
Dim Rs, Gs, Bs, Cmax, Cmin, Delta, Hx As Single
Cmax = Application.Max(Rs, Gs, Bs)
Cmin = Application.Min(Rs, Gs, Bs)
Delta = Cmax - Cmin
Select Case Cmax
Case Cmin
Hx = 0
Case Rs
Hx = (60 * ((Gs - Bs) / Delta)) + IIf(Gs < Bs, 360, 0)
Case Gs
Hx = (60 * ((Bs - Rs) / Delta)) + 120
Case Bs
Hx = (60 * ((Rs - Gs) / Delta)) + 240
End Select




























































































