Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Read a binary (.bin) file in VB

Status
Not open for further replies.

vbakan

MIS
Dec 6, 2006
24
GB
I want to read a binary file in VB and out put as text. COuld any one tell me hoe to do that please
 
I did put up a FAQ on the topic but here are some of the basics:
Code:
fname = Application.GetOpenFilename()
Open fname For Binary As #1
say, to get the ball rolling.

Now I have certain record length issues; perhaps you do to:
Code:
        For j = 1 To reclen
            a1 = AscB(Input(1, #1))
            h1 = Hex(a1)
            If Len(h1) < 2 Then
                h1 = "0" & h1
            End If
            hnum = hnum & h1
            hst = hst & Chr(a1)
        Next
Now, hst is a hex string that has twice the number of characters as bytes you read.

What to do next depends on what you mean by
out put as text

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top