Solved

writing into buffer

Posted on 1998-08-11
1
281 Views
Last Modified: 2010-04-30
I want to read a file in binary mode byte by byte using get and later I want to write the entire file into a buffer so that I can fill the content of the buffer to a variable which I can make use to transfer the file through some protocol.

Briefly I want to read the file and write the content using put to a buffer instead of writing to a disk file.

Can anybody help me out with some sample code.
0
Comment
Question by:lesa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
cymbolic earned 10 total points
ID: 1468556
Basic binary file i/o to read a file would be:
dim x$, l&,y$
open "SomeFileName" for binary as #1
x$=space$(1)  'set input buffer
l&=lof(1)   'get length of file in l&
do
 get #1,,x$   'get one byte
 l&=l&-1
 if <some condition you check for> then
   y$=y$+x$  'make big buffer
 endif
loop until <some condition you need> or l&=0
close #1

Of course if you know how much you need ahead of time, just set x$ to be space$(??) and one get will bring it all in.  If the file is small, you can set x$ to be space$(lof(1)) and read it all in in one big gulp.   Then you can interate through the input buffer x$ and check each character using either the asc or mid$ functions to check for values, then truncate x$ where ever you desire.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question