Results 1 to 3 of 3

Thread: Binary to hex

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    Netherlands
    Posts
    128
    Hi,

    I need to convert a binary string to a hex string.

    The code i've got works great but if i want to convert

    1111111111111111 i get an overflow.

    Thanx Asterix

    ***********THE CODE I'VE GOT************

    Public Function Bin2Dec(Bin) As Integer
    Y = Len(Bin) - 1
    For X = 1 To Len(Bin)
    Bin2Dec = Bin2Dec + ((2 ^ Y)) * (Mid$(Bin, X, 1))
    Y = Y - 1
    Next X
    End Function

    Private Sub Command1_Click()
    Text2.Text = Hex(Bin2Dec(Text1.Text))
    End Sub

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    declare Bin2Dec as long and it works!
    Mark
    -------------------

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    Netherlands
    Posts
    128
    Thanx Mark

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