Option Compare Database Option Explicit Public Function DecToBin(ByVal lngNumber As Long, Optional bytLength As Byte) As String ' Returns string that represents the binary expression for lngNumber. ' ' If bytLength is specified, returned string will be filled with ' leading zeroes up to this length. Dim strBin As String While lngNumber > 0 strBin = (lngNumber Mod 2) & strBin lngNumber = lngNumber \ 2 Wend If bytLength > 0 Then strBin = Right(String(bytLength, "0") & strBin, bytLength) End If DecToBin = strBin End Function
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.