?
Solved

Start reading from beginning of file.

Posted on 2004-08-16
3
Medium Priority
?
230 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
[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
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Burbble earned 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

765 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