Simple Decimal To Binary Converter
This simple code will convert the Long Integers to it's binary Equivalent...
Inputs
Long Integers ( positive ) 1 - 999999999
Assumes
This program is not capable of accepting negative numbers or numbers which are more than 999999999
Returns
if the range is met then this will return the Binary equivalent...
if the input is either non-numeric or not in range ( 1 - 999999999 ) then
it won't continue.....
Rate Simple Decimal To Binary Converter
(3(3 Vote))
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
Simple Decimal To Binary Converter Comments
No comments yet — be the first to post one!
Post a Comment