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
Solved

how to start reading information...

Posted on 1999-01-15
7
153 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
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.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

829 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