Solved

Start reading from beginning of file.

Posted on 2004-08-16
3
226 Views
Last Modified: 2010-05-02
Hi, I have a program that reads data from a binary file, 4kilobytes at a time (using INPUT). My problem is, when i close that file and open a new file to do the same, the program does not start from the beginning of the file, and just reacts as if it has reached the end of the file. How can i tell it to begin reading from the beginning of the file again? Heres my code:

Earlier in the code, a file is opened with the following line:
  Open CD.FileName For Binary As #1
  FileSize = FileLen(CD.FileName) / 4096


The following code is then executed everytime i want the next 4k of data from that file:

 cmdSend.Enabled = False
 Dim DataChunk As String
 If FilePos < FileSize Then
  FilePos = FilePos + 1
  DataChunk = Input(4096, #1)
  Ws.SendData DataChunk
  lblConnection = "Transferring... " & Math.Round((FilePos / FileSize * 100), 0) & "%"
  DoEvents
 Else
  Ws.SendData "FileEnd" & FileLen(CD.FileName)
  FilePos = 0
  cmdSend.Enabled = True
  Close#1
 End If

 
0
Comment
Question by:pyromatt
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Burbble earned 50 total points
ID: 11815599
Try this:

Open CD.FileName For Binary As #1
Seek #1, 1 '<-- add this line

(etc etc...)

-Burbble
0
 

Author Comment

by:pyromatt
ID: 11816244
It works!!! thanks! :)
0
 
LVL 7

Expert Comment

by:Burbble
ID: 11817318
Glad I could help :-)

Thanks for the points.

-Burbble
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
SSRS expression Issue finding a string 10 99
Visual Basic Excel Formatting error 4 140
message box in access 4 52
how to know if my Checkbox is True in VB6.0? 9 65
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

679 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