Nun der Titel dürfte reichen ;-)
Aus 111111 wird 63
Public Function BinToDec(ByVal BinVal As String) As Long
Dim SqrNum As Long = 1
Dim Result As Long = 0
For i As Integer = BinVal.Length - 1 To 0 Step -1
Result += (CLng(BinVal.Substring(i, 1)) * SqrNum)
SqrNum *= 2
Next
Return Result
End Function
1 Kommentare zum Snippet