Page 1 of 1

Showing Hex

Posted: Fri Dec 09, 2005 11:55 pm
by WastingBody
Can someone tell me how to show hex like the weap names in an app.

Posted: Sat Dec 10, 2005 12:52 pm
by superaison
tell me if it workszorz

Code: Select all

Private Sub   HexView(FileName   As     String   )
'put contents of file into textbox1
Dim temp As String , temp2 As String
Dim i As Long , j As Long
Dim leader As String
Dim HexText As String
Dim AsciiText As String
Dim Char As String

'read the file into a string
Open filename For Input As #1
temp2 = Input (Lof(1),#1)
Close #1

'create hex string
If Len(temp2) > 0 Then
    For i = 1 To Len(temp2) Step 8
       leader = String $((6 - Len( Hex (i - 1))), "0" ) & Hex (i - 1) & " "
       HexText = ""
        For j = 0 To 7
            If i + j > Len(temp2) Then
               HexText = HexText & Space$((8 - j) * 3)
                Exit For
            End If
            Char = Format $( Hex ( Asc ( Mid $(temp2, i + j, 1))), "00" )
            If Len( Char ) = 1 Then Char = "0" & Char
           HexText = HexText & Char & " "
        Next j
       AsciiText = Mid $(temp2, i, 8)
       AsciiText = Replace(AsciiText, Chr (9), "." )
       AsciiText = Replace(AsciiText, Chr (10), "." )
       AsciiText = Replace(AsciiText, Chr (13), "." )
       temp = temp & leader & HexText & " " & AsciiText & vbCrLf
    Next i
Else
   temp = vbCrLf
End If

temp = Mid $(temp, 1, Len(temp) - 2)
text1.text = temp

End Sub 

Posted: Sat Dec 17, 2005 9:49 am
by PlasmaGhost
how about in C# now :) lol

Posted: Sat Dec 17, 2005 7:51 pm
by superaison
ill look round.