| | |
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 9: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
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






