Convert A Binary String to A Decimal Number?
Following code shown to convert a binary string to a decimal number.
Public Function Bin_To_Dec(ByVal Bin As String)
‘function to convert a binary number to decimal
Dim dec As Double = Nothing
Dim length As Integer = Len(Bin)
Dim temp As Integer = Nothing
Dim x As Integer = Nothing
For x = 1 To length
temp = Val(Mid(Bin, length, 1))
length = length - 1
If temp <> “0″ Then
dec += (2 ^ (x - 1))
End If
Next
Return dec
End Function