Solved

Read records into a buffer

Posted on 2004-10-01
2
176 Views
Last Modified: 2010-05-02
I have the following type defination in my code

Type ColorChart
    ChartNumber As Long
    EmployeeNumber As Long
    ChartDay As Byte
    ChartMonth As Byte
    ChartYear As Integer
    ChartDeleted As Byte
End Type

this defination is used when reading and writing to a binary file using the following Var

Public CChart As ColorChart

I am currently looping through each records in the binary file to read in the records.  (this is an old app and the data structure was designed before I came along)

I have been told that if I read a couple of records into a Buffer at 1 time that this would be the fastest way of reading the file.

How do I use a buffer - and how do I calculate how may records I can read into a buffer?



0
Comment
Question by:CiaranG
2 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 230 total points
ID: 12199551
You must use an array similar to:

Dim Buffer(10) As ColorChart

Then, don't read 1 structure at a time, but 10
Also you can use a control variable to specify buffer size and another to specify record number of first element. This will increase the access speed noticeably.
0
 

Author Comment

by:CiaranG
ID: 12206976
Well I am reading records using the following

get #chartfileno, (len(colorchart) * looper)+1), colorchart

how do I read 10 records into a buffer at once?



Thanks
CiaranG
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now