Advertisement
2_2002-2004 Miscellaneous #120986

Simple Decimal To Binary Converter

This simple code will convert the Long Integers to it's binary Equivalent...

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Option Explicit
'********************************************'
'***This Function is to just to Return the***'
'***Binary Equivalent for Any long integer***'
'********************************************'
Private Sub Command1_Click()
  
  Dim str1 As String
  
  On Error GoTo a:
  
  str1 = cBin(CLng(Text1.Text))
  
  MsgBox str1
  
  Exit Sub
a:
End Sub
Public Function cBin(a As Long) As String
  
  Dim bal As Long
  Dim str1 As String
  
  bal = a
  
    Do Until a <= 0
      bal = a Mod 2
      If bal = 0 Then
        a = a / 2
      Else
        a = (a - 1) / 2
      End If
      str1 = str1 & CStr(bal)
    Loop
    
    cBin = StrReverse(str1)
    
End Function
Original Comments (3)
Recovered from Wayback Machine