Public Function ToBinary(ByVal Number As Long, Optional Digits As Long = 24) As String
'Created by Lukas
Dim i As Long
Const ZERO As String = "0"
Const ONE As String = "1"
ToBinary = String(Digits, ZERO)
If Number Then
For i = Digits To 0 Step -1
If Number Mod 2 Then
Mid$(ToBinary, i, 1) = ONE
End If
Number = Number \ 2
Next i
End If
End Function
|