Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Gross Faults/Errors With Put and Get
I have been trying to build binary files with contigeous bit patterns in
Excel VBA. I find the Put statement, Put #1, hstart, lv, where hstart is 1& and lv=-1& (32 one-bits), followed by Put#1, hstart,lv, where now hstart is 33& and lv=0&, ends up with a totally screwy series of 0011 bit patterns on the file. The Get statement is inconsistent in output, depending where it is in the compile sequence. Has any body else observed. this? David Heiser |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Gross Faults/Errors With Put and Get
The units for the position argument are BYTEs, not BITs. A Long Integer
variable occupies 32 bits, but that is 4 bytes, not 33. Your 2nd PUT statement should write to byte 5, not byte 33. If you specified hstart as 33 in the 2nd put statement, you've left a gap of 28 bytes in the file. VB/VBA does not overwrite the skipped bytes. What you see in those 28 bytes is whatever was on the disk before you opened the file and allocated the disk space for it. I have never found any problems with the GET statement. Are you confusing bits and bytes here, too? The following code creates a file which a hex viewer displays as FF FF FF FF 01 00 00 00 Sub Test() Dim LV As Long Open "TestFile.BIN" For Binary As #1 LV = -1 Put #1, 1, LV LV = 1 Put #1, , LV Close #1 End Sub On Thu, 23 Sep 2004 16:21:59 -0700, "David A. Heisaer" wrote: I have been trying to build binary files with contigeous bit patterns in Excel VBA. I find the Put statement, Put #1, hstart, lv, where hstart is 1& and lv=-1& (32 one-bits), followed by Put#1, hstart,lv, where now hstart is 33& and lv=0&, ends up with a totally screwy series of 0011 bit patterns on the file. The Get statement is inconsistent in output, depending where it is in the compile sequence. Has any body else observed. this? David Heiser |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Printing faults | Excel Discussion (Misc queries) | |||
summing faults | Excel Discussion (Misc queries) | |||
Excel Throwing Circular Errors When No Errors Exist | Excel Worksheet Functions | |||
Payroll - net to gross? | Excel Discussion (Misc queries) | |||
Unresolved Errors in IF Statements - Errors do not show in results | Excel Worksheet Functions |