Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing faults Seaward Excel Discussion (Misc queries) 1 October 20th 08 06:12 PM
summing faults kevcar40 Excel Discussion (Misc queries) 0 April 5th 07 04:34 PM
Excel Throwing Circular Errors When No Errors Exist MDW Excel Worksheet Functions 1 August 10th 06 02:15 PM
Payroll - net to gross? CD Excel Discussion (Misc queries) 3 February 17th 05 07:48 AM
Unresolved Errors in IF Statements - Errors do not show in results Markthepain Excel Worksheet Functions 2 December 3rd 04 08:49 AM


All times are GMT +1. The time now is 04:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"