Howards submission has some mis-matched parens and doesn't return the number, but when patched, returns the wrong number - but close:

code:
function FadeToBlack($color, $level)

Dim $B, $G, $R

$B=$color/65536
$G=($color mod 65536)/256
$R=$color-($B*65536)-($G*256)

$B = IIF($B<$level, $B, $B-17)
$G = IIF($G<$level, $G, $G-17)
$R = IIF($R<$level, $R, $R-17)

$B = IIF($B<0, 0, $B)
$G = IIF($G<0, 0, $G)
$R = IIF($R<0, 0, $R)

$fadeToBlack = ($B*65536)+($G*256)+$R

endfunction

$c = fadeToBlack(&00DDFF,&DD)

?"value=" DecToHex($c)

returned value is CCEE, should be &00DDDD

-Shawn