CONVERTING BINARY NUMBER TO DECIMAL
CONVERTING BINARY NUMBER TO DECIMAL
Rate CONVERTING BINARY NUMBER TO DECIMAL
(1(1 Vote))
Dim T(500) As String
Dim W(500) As String
Dim Y(500) As Integer
Dim NUM As String
''place 3 command buttons one "clear",second "answer",third "quit" ''place two textboxes one to accept binary number and second to display decimal number as answer ''place two labels one "Binary no" before textbox1 and second "Decimal no" before textbox2
Snippet: Private Sub Cmdanswer_Click()
NUM = Text1.Text
L = Len(NUM)
For I = 1 To L
T(I) = Left(NUM, I)
Next I
For I = 1 To L
W(I) = Right(T(I), 1)
Next I
For I = 1 To L
Y(I) = Val(W(I))
Next I
Let S = 0
For I = L To 1 Step -1
S = S + Y(I) * (2 ^ (L - I))
Next I
Text2.Text = S
End Sub
Private Sub Cmdclear_Click()
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End Sub
Private Sub Cmdquit_Click()
Unload Me
End
End Sub
Private Sub Form_Activate()
Text1.SetFocus
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
End Sub
CONVERTING BINARY NUMBER TO DECIMAL Comments
No comments yet — be the first to post one!
Post a Comment