Results 1 to 3 of 3

Thread: converting hex to binary

  1. #1

    Thread Starter
    Junior Member roars's Avatar
    Join Date
    Jun 2000
    Location
    Northern Ireland
    Posts
    19
    Thanks megatron that was very useful. I also need code that convert hex to binary can anyone help?

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    this is a bit easier to do, because you can just replace the characers in Hex with binary strings

    Code:
    Private Sub HetToBinary(HexString As String) As String
    
    Dim i As Integer
    Dim RetVal As String
    
    For i = 1 To Len(HexString) - 1
    
        Select Case Mid$(HexString,i,1)
    
            Case "0"
                RetVal = RetVal & "0000"
    
            Case "1"
                RetVal = RetVal & "0001"
    
            Case "2"
                RetVal = RetVal & "0010"
    
            Case "3"
                RetVal = RetVal & "0011"
    
            Case "4"
                RetVal = RetVal & "0100"
    
            Case "5"
                RetVal = RetVal & "0101"
    
            Case "6"
                RetVal = RetVal & "0110"
    
            Case "7"
                RetVal = RetVal & "0111"
    
            Case "8"
                RetVal = RetVal & "1000"
    
            Case "9"
                RetVal = RetVal & "1001"
    
            Case "A"
                RetVal = RetVal & "1010"
    
            Case "B"
                RetVal = RetVal & "1011"
    
            Case "C"
                RetVal = RetVal & "1100"
    
            Case "D"
                RetVal = RetVal & "1101"
    
            Case "E"
                RetVal = RetVal & "1110"
    
            Case "F"
                RetVal = RetVal & "1111"
    
        End Select
    
    HexToBinary = RetVal
    
    End Function

  3. #3
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Check out Stevie-O's post on this thread. All bases are covered. No pun intended.

    http://forums.vb-world.net/showthrea...threadid=15507
    Iain, thats with an i by the way!

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