| | |
Need help with Binary files and data types in VB6
![]() |
•
•
Join Date: Jul 2006
Posts: 11
Reputation:
Solved Threads: 0
Hello all,
I am reading (get) and writing (put) values from multiple binary files.
I first have to copy a binary file file1.bin to file2.bin and then I append 1 record to file2.bin.
My problem is when I read the following code I am not getting the values I expect:
The only value that is correct is iFileNo. Everything after that is incorrect. For instance bVer should be 1 but comes out as 0. lNumber of Files should be 70 but comes out as 6816000, etc
Any help with this matter is greatly appreciated.
Thank you.
I am reading (get) and writing (put) values from multiple binary files.
I first have to copy a binary file file1.bin to file2.bin and then I append 1 record to file2.bin.
My problem is when I read the following code I am not getting the values I expect:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim iFileNo as Integer Dim bVer as Byte Dim lNumberOfFiles as Long Dim lBufferSize as Long Dim tBuffer as String FileNum = FreeFile Open tBinaryFilepath For Binary Access Read Lock Read Write As #FileNum Get #FileNum, , iFileNo Get #FileNum, , bVer Get #FileNum, , lNumberOfFiles Get #FileNum, , lBufferSize tBuffer = String(lBufferSize, "") Get #FileNum, , tBuffer
The only value that is correct is iFileNo. Everything after that is incorrect. For instance bVer should be 1 but comes out as 0. lNumber of Files should be 70 but comes out as 6816000, etc
Any help with this matter is greatly appreciated.
Thank you.
•
•
Join Date: Jul 2006
Posts: 11
Reputation:
Solved Threads: 0
Hey Comatose,
I do have a loop, but did not include in my example.
I used a hex editor to see exactly what the binary file contained.
Apparently, even if the first value was written as an integer in delphi 4 bytes, I had to use a long in VB6 to capture all 4 bytes. So now I figured out what I need to do to make it work. I am not sure I fully understand it though.
Here is what the first few fields look like according to the hex editor
39 1B 00 00 01 46 ...
__________ __ __
Thank you.
I do have a loop, but did not include in my example.
I used a hex editor to see exactly what the binary file contained.
Apparently, even if the first value was written as an integer in delphi 4 bytes, I had to use a long in VB6 to capture all 4 bytes. So now I figured out what I need to do to make it work. I am not sure I fully understand it though.
Here is what the first few fields look like according to the hex editor
39 1B 00 00 01 46 ...
__________ __ __
Thank you.
•
•
Join Date: Jul 2006
Posts: 11
Reputation:
Solved Threads: 0
Follow up to my Binary file problem...
Hello all,
I am trying to write a string preceded by a length field in a binary file
Here is an example
I am using a Hex editor to view the binary file.
After the first Put statement I see the following
08 00 00 00 ....
After the second Put statement I see the following
08 00 00 00 08 00 08 00 55 73 65 72 4E 61 6D ........UserName
My problem is that I see an extra 4 bytes of stuff preceding UserName, above in Bold. I do not want the extra bytes because they are messing up my binary file.
Any ideas are greatly appreciated.
Thank you.
Hello all,
I am trying to write a string preceded by a length field in a binary file
Here is an example
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim tNameBin as String Dim lBufferSize as Long : 'Name Field tNameBin = "UserName" lBufferSize = Len(tNameBin) Put #TempFileNum, , lBufferSize Put #TempFileNum, , tNameBin
I am using a Hex editor to view the binary file.
After the first Put statement I see the following
08 00 00 00 ....
After the second Put statement I see the following
08 00 00 00 08 00 08 00 55 73 65 72 4E 61 6D ........UserName
My problem is that I see an extra 4 bytes of stuff preceding UserName, above in Bold. I do not want the extra bytes because they are messing up my binary file.
Any ideas are greatly appreciated.
Thank you.
Last edited by cyman73; Aug 4th, 2006 at 8:25 pm.
![]() |
Similar Threads
- C++ Data Types (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: VB source code for Internet base webcam
- Next Thread: Novice help appreciated please
Views: 4570 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 7 429 access activex add ado append array basic beep blackjack bmp c++ calculator calendar channel9 click code college component copy data database date delete dissertationtopic edit error excel file form game grid group hardware header icon image interaction key keypress label list listview liveperson machine macro match measure messagebox metadata microsoft nice noob number object open oracle os outlook pdf picture powerpoint prime print printer problem prompt query random range-objects readfile report reports save score search sites size sort sound spectateswamp sql struct sum table timer variable variables vb vb6 vb6.0 vba visual visualbasic web window windows






