VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



DecToBin

by Newsgroup Posting (15 Submissions)
Category: Math/Dates
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

Converting numbers to binary
[email protected] (Alan Davis)

Rate DecToBin

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

Download this snippet    Add to My Saved Code

DecToBin Comments

No comments have been posted about DecToBin. Why not be the first to post a comment about DecToBin.

Post your comment

Subject:
Message:
0/1000 characters