S
Sasa
Hello,
I got this function converting binary numbers (string
form) into decimal numbers (integer form).
-----------------------------------------
Function Bin2Dec(Binar As String) As Integer
Dim i As Integer, n As Integer, D As String
For i = 1 To 15
If IsNumeric(i(Binar, i, 1)) Then
D = D + Mid(Binar, i, 1)
End If
Next
For i = 1 To 8
n = n + CInt(Mid(Binar, i, 1)) * 2 ^ (8 - i)
Next
Bin2Dec = n
End Function
-----------------------------------------
The problem is that function converts only the the numbers
8-digits long. I got also the binary numbers long 2 or 9
digits long. How should I update the code to have the
ability to convert the binary numbers with count of digits
less and more then 8.
Thanks.
Regards.
I got this function converting binary numbers (string
form) into decimal numbers (integer form).
-----------------------------------------
Function Bin2Dec(Binar As String) As Integer
Dim i As Integer, n As Integer, D As String
For i = 1 To 15
If IsNumeric(i(Binar, i, 1)) Then
D = D + Mid(Binar, i, 1)
End If
Next
For i = 1 To 8
n = n + CInt(Mid(Binar, i, 1)) * 2 ^ (8 - i)
Next
Bin2Dec = n
End Function
-----------------------------------------
The problem is that function converts only the the numbers
8-digits long. I got also the binary numbers long 2 or 9
digits long. How should I update the code to have the
ability to convert the binary numbers with count of digits
less and more then 8.
Thanks.
Regards.