DecToBin
Converting numbers to binary
[email protected] (Alan Davis)
Rate DecToBin
(2(2 Vote))
Public Function DecToBin(ByVal DecNumber As Currency) As String
On Error GoTo DecToBin_Finally
Dim BinNumber As String
Dim i%
For i = 64 To 0 Step -1
If Int(DecNumber / (2 ^ i)) = 1 Then
BinNumber = BinNumber & "1"
DecNumber = DecNumber - (2 ^ i)
Else
If BinNumber <> "" Then
BinNumber = BinNumber & "0"
End If
End If
Next
DecToBin = BinNumber
DecToBin_Finally:
If Err <> 0 Or BinNumber = "" Then DecToBin = "-E-"
Exit Function
End Function
DecToBin Comments
No comments yet — be the first to post one!
Post a Comment