Dec 222017
 
This is a sample application that illustrates the coding needed to use a Huge Array in conjunction with a Grid Control using Visual Basic.
File HUGEGR.ZIP from The Programmer’s Corner in
Category BASIC Language
This is a sample application that illustrates the coding needed to use a Huge Array in conjunction with a Grid Control using Visual Basic.
File Name File Size Zip Size Zip Type
HUGEGRID.BAS 1343 401 deflated
HUGEGRID.DOC 7224 3113 deflated
HUGEGRID.FRM 11159 5040 deflated
HUGEGRID.MAK 77 59 deflated
TPCREAD.ME 199 165 deflated

Download File HUGEGR.ZIP Here

Contents of the HUGEGRID.DOC file


HugeGrid 1.0
Copyright 1991 Nelson Ford, PsL
P.O.Box 35705 Houston, TX 77235-5705


LICENSE

1. You may freely use and distributed this code in applications in which
this code makes up a small part of the program.

2. You may freely distribute this code to other VB programmers, including
uploading it to BBS's or for a disk fee, as long as all related files
are distributed together and without any changes.

All I ask for the use of this code is that if you find a better way to do
something than the methods I've used, I would appreciate your letting me know.



REQUIREMENTS

Visual Basic is required, of course, and HUGEARR.DLL and GRID.VBX.

HUGEARR.DLL and GRID.VBX are not included with this set of files. They are
available in separate archives on the MSLANG Forum's Data Libraries for
downloading or you can get them on disk from PsL. (See the end of this file.)


PURPOSE

This is a sample application whose only purpose is to illustrate the coding
needed to use a Huge Array in conjunction with a Grid Control. Even if you are
using one but not the other, this sample code should come in handy. Getting
everything to work right under all circumstances took about 30 hours or more
of coding.


INTRODUCTION

The Huge Array DLL and the Grid Control VBX were produced by Microsoft and
given to beta testers, but not included with Visual Basic when released.

It appears that they are bug-free, but probably were not included because they
are not very robust. For example, getting Text out of a Grid cell by having to
change the Grid.Row and Grid.Col is a very inefficient way to do things,
neither is having to access a Huge Array like you would a data file.

Nevertheless, if you HAVE to have either an array larger than 64k (VB's usual
limit) or a Grid control - you'll be glad that MS decided to release these to
the public as freebies.


HUGE ARRAY VS RANDOM DATA FILE

As you will see, sorting a 5000-element Huge Array takes a lot of time - two
minutes on a 386-33. I haven't had a chance yet to compare the performance of
a Huge Array versus a random access data file. (Scrolling seems to go at a
respectable clip.)

It's possible that with a sufficiently large disk cache, a random access file
would be as fast as the Huge Array and would have the advantage of being more
secure as data is written to the disk when added or deleted. However, if your
user is not using a large enough cache, then performance could be seriously
degraded by using a random access disk file.

Because getting data to and from a Huge Array is more like accessing a Random
access data file than using an actual in-memory data array, it should be
possible to use most of these same routines with a data file if you do decide
to go that way.


DOCUMENTATION

HUGEARR.DLL - This file goes into some directory in your PATH. This file and
the next one are not included in this set. See REQUIREMENTS.

GRID.VBX - This file is loaded into your application via Alt-F-d "Add File".

HUGEGRID.BAS - The Declares in the Global file come with the HugeArr.DLL.
Print the documentation that comes with HugeArr.DLL for reference in using it.


HUGEGRID.FRM -

General
DecrLastEl & IncrLastEl

When you delete an entry, several pointers have to be adjusted. This Sub
makes sure that wherever you need to decrease LastElement, everything else
gets done too. IncrLastEl does the same for adding entries.

General
Sub FillGrid(StartPt, StopPt, StartRow)

This routine gets data from the Array and puts it in the grid.
StartPt and StopPt are the pointer numbers to start and stop with.
StartRow says what row of the grid to start with.

General
Function GetEl(x)

Gets the element of the Array that Pointer&(x) points to.
You could format or otherwise manipulate the data at this point if needed.

General
ScrollUp & ScrollDown
Lets you scroll selected rows in the Grid up or down. Given the kludgy way
that data has to moved from one Grid cell to another, it may be just as quick
to use the FillGrid routine to read the data in from the HugeArray again, and
it would save all this code.


Form
Load:

In setting up your grids, you may have to experiment (going back and forth
between design and run-time) to find the desired column widths, since I
haven't found any way to change them during design time.

Most of the VScroll values shown can be set at design time. They are included
here to make them easier to see.

For ease of coming up with a lot of different text, numbers were used to fill
the array. However, these ARE strings and when sorted, they are sorted as
strings, not as numbers. (So you will see 1.1 10.1 100.1 ... 2.1 20.1, etc.)

If you enter a number in the Text box and select Insert, it will be entered
alphabetically, not numerically. You could easily change the code to treat the
data as numbers rather than text simply by using VAL() everywhere that data
variables are used.

After loading up the array, the end of the array is displayed in the Grid. You
could just as easily pick any other part of the array for the initial display,
but don't forget to change Vscroll1.Value accordingly. (eg: If you display
elements 1 - 10, set Vscroll1.Value to 10.)

Form
B_Sort
This is a QuickSort algorithm, which is one of the fastest general sorting
algorithm available. Although numeric data is used for ease of filling up an
array with different data, the numbers are store as strings and will be sorted
in string order. (eg: 10 100 1000 before 20)

Form
B_Del
Deletes an array element. To save time, the element is not actually removed
from the array. An array (Deleted&) is set up for keeping track of deleted
entries and reusing that space on subsequent Adds.

Form
B_Find
Does a binary search.

Form
B_Insert

This is an alphabetic insert. It calls B_Find and then inserts the new data.
This took a lot of time to work out the special cases, such as inserting a
number at the beginning or end of the file.

Form
B_Quit
Be sure to quit the demo by clicking on Quit. This frees up memory for Windows
that was used by the Huge Array.




WHERE TO GET VB STUFF

This program was written by Nelson Ford, PsL.

You can find a lot of routines, sample programs, custom controls, and DLL's on
Microsoft's MSLANG forum on CompuServe.

My company, Public (software) Library, also distributes a lot of VB goodies
and programs. Call or write for a free copy of our monthly magazine and
catalog:

Public (software) Library
P.O.Box 35705
Houston, TX 77235-5705
Orders: 800-242-4PsL
Tech Support: 713-524-6394
FAX: 713-524-6398
CIS: 71355,470


 December 22, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)