Solved

how to start reading information...

Posted on 1999-01-15
7
151 Views
Last Modified: 2010-05-03
I would like to make a control to put a bunch of files together and then seperate them. My first problem is... how do I open the file(meaning any file) and start reading the information of that file into VB? It should not matter what file it is or what it contains... The computer sees it the same way. (Just a bunch of numbers) right???
0
Comment
Question by:rpg_rpg
7 Comments
 
LVL 6

Expert Comment

by:clifABB
ID: 1456622
Use:
Open "TESTFILE" For Binary Access Write As #1

Then use Get to input the data:
Get #1, , vVar


0
 
LVL 4

Expert Comment

by:chabaud
ID: 1456623
... Access Read ...
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1456624
Good catch Chabaud!

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:rpg_rpg
ID: 1456625
so what is vVar  going to = ? the entire file or just the first byte... And after?
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1456626
Vvar will equal the first byte the first time it is called, every subsequent call, it will be equal to the next byte.

So, to read an entire file a byte at a time, this code will work:
  Dim btVar  As Byte
  Dim nFile  As Integer

  nFile = FreeFile

  Open "TESTFILE" For Binary Access Read As #nFile
  Do Until EOF(nFile)
    Get #nFile, , btVar

    'Do what you want with btVar
    Debug.Print btVar
  Loop
  Close #nFile

(Thanks to chabaud for pointing out my Access Write error)
0
 

Author Comment

by:rpg_rpg
ID: 1456627
clifABB: you did not use this as an answer. Could you please.
0
 
LVL 6

Accepted Solution

by:
clifABB earned 200 total points
ID: 1456628
Thank you.

So, to read an entire file a byte at a time, this code will work:
  Dim btVar  As Byte
  Dim nFile  As Integer

  nFile = FreeFile

  Open "TESTFILE" For Binary Access Read As #nFile
  Do Until EOF(nFile)
    Get #nFile, , btVar

    'Do what you want with btVar
    Debug.Print btVar
  Loop
  Close #nFile

0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

803 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