getting hex values from any file
getting hex values from any file
getting hex values from any file
getting hex values from any file
getting hex values from any file
getting hex values from any file getting hex values from any file getting hex values from any file getting hex values from any file getting hex values from any file getting hex values from any file getting hex values from any file getting hex values from any file
getting hex values from any file getting hex values from any file
getting hex values from any file
Go Back  Xtreme Visual Basic Talk > > > getting hex values from any file


Reply
 
Thread Tools Display Modes
  #1  
Old 02-13-2005, 09:28 PM
rookie7799 rookie7799 is offline
Newcomer
 
Join Date: Feb 2005
Posts: 2
Angry getting hex values from any file


Hello guys,
Basically I open a file in BinaryMode and get hex values from it ...

When I was using the application i wrote in VB6 everything worked:
here is a part of it
Code:
While file_name$ <> ""

    fnum = FreeFile
    Open file_name$ For Binary As #fnum
    num_bytes = LOF(fnum)
    ReDim bytes(1 To num_bytes)
    Get #fnum, , bytes
    
    Close fnum

    ' Display the data.
    unk = Chr$(191)
    i = num_bytes - 150
    temp = 0
    
    Do While i <= num_bytes
        If temp < 100 Then
        line1 = Format$(i, "@@@@@@: ")
        line2 = "    "
        For j = 0 To 7
            If i + j > num_bytes Then
               line1 = line1 & "   "
            Else
                ch = bytes(i + j)
                line1 = line1 & Format$(Hex$(ch), "@@ ")
...
...
so, i desided to try to do the same thing in vb.net :

Code:
        Dim fnum As Integer
        Dim num_bytes As Long
        Dim bytes() As Byte
        Dim txt, txt2 As String
        Dim line1 As String
        Dim line2 As String
        Dim unk, FilesPath As String
        Dim ch As Integer
        Dim i As Double
        Dim j As Double
        Dim temp As Double
        Dim file_name$

...
...
...
While file_name$ <> ""

            fnum = FreeFile()
            FileOpen(fnum, fpath & "\" & file_name$, OpenMode.Binary)
            num_bytes = LOF(fnum)
            ReDim bytes(num_bytes)
            FileGet(fnum, bytes)
            FileClose(fnum)

            unk = Chr(191)
            i = num_bytes - 150
            temp = 0

            Do While i <= num_bytes
                If temp < 100 Then
                    line1 = Format$(i, "@@@@@@: ")
                    line2 = "    "
                    For j = 0 To 7
                        If i + j > num_bytes Then
                            line1 = line1 & "   "
                        Else
                            ch = bytes(i + j)
                            line1 = line1 & Format$(Hex$(ch), "@@ ")
                            If ch >= 32 Then
                                line2 = line2 & Chr(ch)
                            ElseIf ch = 0 Then
                                line2 = line2 & Chr(ch)
                                temp = temp + 1
                            Else
                                line2 = line2 & unk
                            End If
                        End If
                    Next j
                    txt = txt & line1 & line2 & vbCrLf
                    i = i + 8
                Else
BUT on FileGet(...) i get this error:
An unhandled exception of type 'System.IO.EndOfStreamException' occurred in microsoft.visualbasic.dll

Additional information: Unable to read beyond the end of the stream.

have no idea why
HeLp anyone ...
Reply With Quote
  #2  
Old 02-13-2005, 11:28 PM
rookie7799 rookie7799 is offline
Newcomer
 
Join Date: Feb 2005
Posts: 2
Question Open jpg in hex

HOW????
i posted earlier - no one answered...

I open file in Binary mode

...
...
fnum = FreeFile()
FileOpen(fnum, fpath & "\" & file_name$, OpenMode.Binary)
num_bytes = LOF(fnum)
ReDim bytes(num_bytes)

FileGet(fnum, bytes) <- IT GIVES ME ERROR

FileClose(fnum)

error:
An unhandled exception of type 'System.NullReferenceException' occurred in microsoft.visualbasic.dll

Additional information: Object reference not set to an instance of an object.

WHY WHY WHY
Reply With Quote
  #3  
Old 02-14-2005, 02:58 PM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

don't use the old legecy code(vb6) use vb.net instead.

Look in the System.IO Assembly

then all you need to do is convert each 2 bytes to a hex decimal value.

the pig..
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
getting hex values from any file
getting hex values from any file
getting hex values from any file getting hex values from any file
getting hex values from any file
getting hex values from any file
getting hex values from any file getting hex values from any file getting hex values from any file getting hex values from any file getting hex values from any file getting hex values from any file getting hex values from any file
getting hex values from any file
getting hex values from any file
 
getting hex values from any file
getting hex values from any file
 
-->