Solved

how to start reading information...

Posted on 1999-01-15
7
160 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
[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
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

726 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