Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

how to start reading information...

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
rpg_rpg
Asked:
rpg_rpg
1 Solution
 
clifABBCommented:
Use:
Open "TESTFILE" For Binary Access Write As #1

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


0
 
chabaudCommented:
... Access Read ...
0
 
mark2150Commented:
Good catch Chabaud!

0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
rpg_rpgAuthor Commented:
so what is vVar  going to = ? the entire file or just the first byte... And after?
0
 
clifABBCommented:
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
 
rpg_rpgAuthor Commented:
clifABB: you did not use this as an answer. Could you please.
0
 
clifABBCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now