Nice... but for large numbers it returns something like: 1.001101011E+28 and I don't think anyone wants that...
I modified your code to return the number as a string, and the result is better
VB Code:
Private Function DecToBinStr(ByVal Dec As Double) As String
Dim strTValue As String, strValue As String
Do
strTValue = Str(Dec Mod 2)
strValue = strTValue & strValue
Dec = IIf(Right(Str(Dec), 2) = ".5", Dec - 0.5, IIf(Dec Mod 2 > 0, Dec - 1, Dec)) / 2
Loop Until Dec = 0
DecToBinStr = Replace(strValue, " ", "")
End Function
Example of what i'm talking about
VB Code:
Debug.Print DecToBin(324534523) ' returns 1.001101011E+28
Debug.Print DecToBinStr(324534523) ' returns 10011010110000000000011111011