|
-
Sep 14th, 2001, 08:53 AM
#1
Thread Starter
Lively Member
-
Sep 14th, 2001, 09:04 AM
#2
Lively Member
A long way round would be reading this info through 4, 8 bit (256) lumps and then converting to binary, putting them together, converting them back so that they end up as 32 bit numbers.
Sorry I can't do better...
Flustor
My Spidey senses are tingling!
-
Sep 14th, 2001, 12:05 PM
#3
Re: Reading a binary file?
Originally posted by John Graham
Hi,
I have a binary file which has a format consisting of an X value stored as a 32 bit signed integer, a Y value stored as a 32 bit signed integer and a 24 bit character array etc etc.
Do you mean a 24 byte character array?
-
Sep 14th, 2001, 12:33 PM
#4
Assuming you do, you can open the file as a random access file, which is easier:
VB Code:
'This declares our data type used to access the file
'Put it in the top of the form (the General Declarations Area)
'You might want to give it a more meaningful name than "Info"
Private Type Info
X As Long
Y As Long
Chars(1 To 24) As Byte
End Type
'This code will read all the data in the file and display the X and Y
'values, and also the text in the Character array on the form. I
'don't think you will have much trouble uderstanding it and
'applying it for your app. You might want to change it so it uses
'the FreeFile function instead of just using 1 for the file number.
'If you don't know how, just ask.
Dim Rec As Info
Dim I As Long
Open "c:\testfile" For Random As #1 Len = 32
Do
I = I + 1
Get #1, I, Rec
If EOF(1) Then
Exit Do
End If
Print "X = "; Rec.X; "; Y = "; Rec.Y; "; Chars = "; StrConv(Rec.Chars, vbUnicode)
Loop
Close #1
-
Sep 17th, 2001, 03:22 AM
#5
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|