However, here's a more detailed version with the right stuff in there

Code:
Private Function den2bin(den As Double)
dim sta as double, x as string
'Sta = starting value.  The value in this case is a 24-bit number and the value
'of the 25th bit...it is divided by 2 at each point and each successive number
'is the value of the next lowest bit...sta/2 is the 24th bit, /2 again is the 23rd
'until you get to 1 which is the 1st bit
sta = 16777216
For b = 1 To 24
sta = sta / 2
'X here is unimportant...it's a temporary string storing the binary data as it
'is being built
If den And sta Then x = x & "1" Else x = x & "0"
Next b
'This is how functions work.  Notice how the first part "den2bin" is the name
'of this function...saying "den2bin = x" is saying to return the value of x as
'the returned value from the function...functions return values :-P
den2bin = x
End Function
Yes, I removed the step -1 and made it 1 to 24...I originally was going to use the original idea with the array but decided against it :-)