+ Reply to Thread
Results 1 to 5 of 5

Hexadecimal to Binary Conversion

  1. #1
    sean_f
    Guest

    Hexadecimal to Binary Conversion

    hi all,

    does anyone know how to convert from hexadecimal
    00017fff
    or
    3

    to binary
    00000000000000010111111111111111
    or
    011

    Many Thanks
    sean


  2. #2
    Gary Keramidas
    Guest

    Re: Hexadecimal to Binary Conversion

    install the analysis toolpak add in, then enter this

    =HEX2BIN("F",8)


    --


    Gary


    "sean_f" <[email protected]> wrote in message
    news:[email protected]...
    > hi all,
    >
    > does anyone know how to convert from hexadecimal
    > 00017fff
    > or
    > 3
    >
    > to binary
    > 00000000000000010111111111111111
    > or
    > 011
    >
    > Many Thanks
    > sean
    >




  3. #3
    sean_f
    Guest

    Re: Hexadecimal to Binary Conversion Without Using Analysis Tool Pak

    Unfortunately I cannot rely on users to have the tool pak installed.

    Thanks

    sean



    Gary Keramidas wrote:
    > install the analysis toolpak add in, then enter this
    >
    > =HEX2BIN("F",8)
    >
    >
    > --
    >
    >
    > Gary
    >
    >
    > "sean_f" <[email protected]> wrote in message
    > news:[email protected]...
    > > hi all,
    > >
    > > does anyone know how to convert from hexadecimal
    > > 00017fff
    > > or
    > > 3
    > >
    > > to binary
    > > 00000000000000010111111111111111
    > > or
    > > 011
    > >
    > > Many Thanks
    > > sean
    > >



  4. #4
    Michel Pierron
    Guest

    Re: Hexadecimal to Binary Conversion

    Hi sean_f;

    Private Function HexToBin$(HexNum$)
    Dim i As Byte, B As String * 1
    Dim lNum&: lNum = Val("&H" & HexNum)
    Do
    If lNum And 2 ^ i Then B = "1" Else B = "0"
    HexToBin = B & HexToBin
    i = i + 1
    Loop Until 2 ^ i > lNum
    End Function

    Sub Test
    MsgBox HexToBin("00017FFF"), 64
    End Sub

    Regards,
    MP


    "sean_f" <[email protected]> a écrit dans le message de news:
    [email protected]...
    > hi all,
    >
    > does anyone know how to convert from hexadecimal
    > 00017fff
    > or
    > 3
    >
    > to binary
    > 00000000000000010111111111111111
    > or
    > 011
    >
    > Many Thanks
    > sean
    >




  5. #5
    Leo Heuser
    Guest

    Re: Hexadecimal to Binary Conversion

    "sean_f" <[email protected]> skrev i en meddelelse
    news:[email protected]...
    > hi all,
    >
    > does anyone know how to convert from hexadecimal
    > 00017fff
    > or
    > 3
    >
    > to binary
    > 00000000000000010111111111111111
    > or
    > 011
    >
    > Many Thanks
    > sean
    >


    Hi Sean

    Here's a general function to convert from one
    number system to another:

    Function Conv(Figure As String, _
    FromBase As Integer, _
    ToBase As Integer, _
    Optional NumberOfDigits As Integer) As String
    'Leo Heuser, October 1999
    '=conv(Figure,FromBase,ToBase,NumberOfDigits)
    'Examples: =conv(1234,6,16,6) or =conv("45ff",16,2,32)
    'If NumberOfDigits is set to 0, left out or set to fewer digits
    'than are in the result, the result will be displayed without
    'leading zeroes.
    'The setup will convert a number from base 2-16
    'to another base 2-16, but the string Digits can be
    'expanded to Z, and thereby covering base 2 through 36
    'If the line "Figure = UCase(Figure)" is deleted, it's possible
    'to place lower case letters in Digits to cover base 2-62.
    'Please keep the above text, if you pass on this routine.

    Dim Digits As String
    Dim ToBaseTen As Long
    Dim Dummy As Variant
    Dim Counter As Integer
    Dim Result As String
    Conv = "Input error"
    Digits = "0123456789ABCDEF"
    If ToBase > Len(Digits) Then Exit Function
    Figure = UCase(Figure)
    For Counter = 1 To Len(Figure)
    Dummy = Mid$(Figure, Counter, 1)
    If InStr(Left$(Digits, FromBase), Dummy) = 0 Then
    Exit Function
    Else
    ToBaseTen = ToBaseTen + (InStr(Digits, Dummy) - 1) * _
    (FromBase ^ (Len(Figure) - Counter))
    End If
    Next Counter
    While ToBaseTen > 0
    Result = Mid$(Digits, (ToBaseTen Mod ToBase) + 1, 1) & Result
    ToBaseTen = Int(ToBaseTen / ToBase)
    Wend
    If NumberOfDigits = 0 Or NumberOfDigits < Len(Result) Then
    Conv = Result
    Else
    Conv = Right$(String$(NumberOfDigits - Len(Result), "0") & _
    Result, NumberOfDigits)
    End If
    End Function


    --
    Best regards
    Leo Heuser

    Followup to newsgroup only please.




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1