VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



convert Binary numbers into Denary numbers and viceversa

by Richard Savage (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 18th October 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

convert Binary numbers into Denary numbers and viceversa

Rate convert Binary numbers into Denary numbers and viceversa



    Dim Denary As Integer
    Dim Digit As Integer
    Dim Answer As String
    Denary = txtDenary
        Do
            Digit = Denary Mod 2
            Denary = Denary \ 2
            Answer = Digit & Answer
            txtBinary = Answer
        Loop Until Denary = 0
End Sub

Private Sub CmdDenary_Click()
    Dim CurrDenMul As Integer
    Dim CurrDenPos As Integer
    Dim CurrDenChr As Integer
    CurrDenMul = 1
    DenaryNumber = txtBinary
    
        For Position = 0 To (Len(DenaryNumber) - 1)
            CurrDenPos = Len(DenaryNumber) - Position
            CurrDenChr = Mid(DenaryNumber, CurrDenPos, 1)
            BinaryNumber = BinaryNumber + (CurrDenMul * CurrDenChr)
            CurrDenMul = CurrDenMul * 2
        Next Position
            txtDenary = BinaryNumber
            BinaryNumber = 0
            DenaryNumber = 0
End Sub

Private Sub CmdReset_Click()
    txtBinary.Text = "Enter Binary No."
    txtDenary.Text = "Enter Denary No."
End Sub

Private Sub txtBinary_Click()
    txtBinary.Text = ""
    txtDenary.Text = ""
End Sub

Private Sub txtDenary_Click()
    txtBinary.Text = ""
    txtDenary.Text = ""
End Sub


Download this snippet    Add to My Saved Code

convert Binary numbers into Denary numbers and viceversa Comments

No comments have been posted about convert Binary numbers into Denary numbers and viceversa. Why not be the first to post a comment about convert Binary numbers into Denary numbers and viceversa.

Post your comment

Subject:
Message:
0/1000 characters