二到十
Dim a As String
Dim b As Integer
Dim i As Integer
Dim t As Integer
a = InputBox("二进制数")
For i = 1 To Len(a) If Not ((Mid(a, i, 1) >= "0") Or (Mid(a, i, 1) >= "1")) Then MsgBox "数据错" Exit Sub End If
Next i
b = 0
For i = 1 To Len(a) t = Asc(Mid(a, i, 1)) - 48 b = b * 2 + t
Next i
Print b