'因十進位轉二進位已張貼過,故不重複貼出。Public Class Form1
Dim str1 As String
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim a As Integer
Dim tol As Integer
str1 = InputBox("請輸入您想要計算的二進位數值")
For i = 1 To Len(str1)
a = Mid(str1, i, 1)
If a = 1 Then
tol = tol + 2 ^ (Len(str1) - i)
Else
tol = tol
End If
Next
MsgBox(tol)
End Sub
End Class
0 留言