Results 1 to 4 of 4

Thread: Binary To Decimal

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    Norwich/Reading
    Posts
    5

    Exclamation

    I need to change a string which is a 12 bit binary value into its decimal equivilant.

    Any easy way?

    Cheers in advance

    Andy Dunn


  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Go back to your original question.

    http://forums.vb-world.net/showthrea...threadid=15507

    Stevie-O has the solution.

    call it like this.
    Code:
    MsgBox CvtBase("000000001111", 2, 10)
    Iain, thats with an i by the way!

  3. #3
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Hello Andy Dunn,

    I think this is the most easiest way

    Private Sub Command1_Click()
    Answer = 0
    For N = 0 To Len(Text1.Text) - 1
    Answer = Answer + Mid(Text1.Text, (Len(Text1.Text) - N), 1) * 2 ^ N
    Next

    End Sub


    Michelle.

  4. #4
    Addicted Member
    Join Date
    Mar 2000
    Location
    Netherlands
    Posts
    128

    Smile

    I use this function to convert:

    Function conv_bin_dec(bite) As Integer

    Y = Len(bite) - 1


    For x = 1 To Len(bite)
    conv_bin_dec = conv_bin_dec + ((2 ^ Y)) * (Mid$(bite, x, 1))
    Y = Y - 1
    Next x

    End Function
    Remember Programmers don't sleep

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width