Preview

Data Structures: Vb and Vba Offer Two Options: Arrays and Collections

Good Essays
Open Document
Open Document
877 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Data Structures: Vb and Vba Offer Two Options: Arrays and Collections
This month is devoted to data structures. This isn 't a computer science course, so let 's define a data structure as a data holder--something that holds whatever data we need while our program executes. Visual BASIC and VBA use two basic data structures: the array and the collection. This month when I say VB, I also mean VBA.

ARRAYS

Most VB programmers are familiar with the array (figure 1). An array can be single or multidimensional, which means it can have rows and columns. While the array is the most commonly used data structure, it 's not the best choice for at least two reasons. The first is data access. To find something within the array, you have to know exactly what you want. If you knew that, you wouldn 't have to look, would you? To search for an item, you must iterate through the array.

[FIGURE 1 OMITTED]

The second reason is that the array must be dimensioned to a known limit. Once set, it 's not easy to add an item after that limit is reached. For example, if you have a list of four people, you can 't add a fifth person until you resize the array using ReDim or ReDim Preserve. ReDim resizes the array and clears any existing values, while ReDim Preserve resizes and keeps any existing values. Also, the upper limit of the array can 't be a dynamic variable. An exception to the dimensioning rule is using an array with a command such as Split (figure 2).

[FIGURE 2 OMITTED]

If the array isn 't dimensioned, the Split command dimensions and fills the array on the fly. Arrays are zero-based in VBA (and in VB, although you can use the Option Base statement to change it). In most cases, the array is limited to a single data type.

COLLECTIONS

A collection (figure 3) is usually a better choice for a data structure. All AutoCAD programmers have used collections whether they realize it or not, because AutoCAD uses them. Layers and blocks are two of the most commonly accessed collections within AutoCAD. A collection differs from an array in



Bibliography: for "Data structures: VB and VBA offer two options: arrays and collections" Mike Tuersley "Data structures: VB and VBA offer two options: arrays and collections". CADalyst. August 2004. FindArticles.com. 30 Oct. 2007. http://findarticles.com/p/articles/mi_m0BLL/is_8_21/ai_n9537860Continued from page 1. Previous - 1 - 2

You May Also Find These Documents Helpful

  • Satisfactory Essays

    What limitations have you or someone you know encountered in the past in using nonrelational structures (such as in a Microsoft® Excel® or Word file) to store data? What were the advantages?…

    • 644 Words
    • 4 Pages
    Satisfactory Essays
  • Powerful Essays

    Nt1330 Unit 1 Study Guide

    • 1178 Words
    • 5 Pages

    To define the storage structure and access methods : Database administrator decide how the data represented in database and described by writing the storage structure definition and also specify the mapping between storage structure definition and the conceptual…

    • 1178 Words
    • 5 Pages
    Powerful Essays
  • Good Essays

    Arrays store items that have the same type of data type like a group of employees’ names and social security numbers for a team of 2000 personal. Pointer is a variable that greatly extends the power and flexibility of a program, each memory location that is used to store data value has an address. The address provides the means for a PC hardware to reference a particular data item.…

    • 485 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Array Structure Paper

    • 833 Words
    • 4 Pages

    “An array is a collective name given to a group of similar quantities. These similar quantities could be percentage marks of 100 students, number of chairs in home, or salaries of 300 employees or ages of 25 students. Thus an array is a collection of similar elements. These similar elements could be all integers or all characters, and so on” (Thompson, 2007). Building an array can be confusing for the Bug Blasters can be very confusing for a programmer who does not fully understand how they work.…

    • 833 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    Visual Basic uses ________ values to represent characters such as A, B, and C in memory.…

    • 2759 Words
    • 44 Pages
    Powerful Essays
  • Powerful Essays

    It 210

    • 2960 Words
    • 12 Pages

    Although the value of a variable may change during execution of a program, in all our programs so far, a single value has been associated with each variable name at any given time. In this chapter, we will discuss the concept of an array—a collection of variables of the same type and referenced by the same name. We will discuss one-dimensional arrays (lists) at length and focus briefly on twodimensional arrays (tables). You will learn how to set up and use arrays to accomplish various tasks.…

    • 2960 Words
    • 12 Pages
    Powerful Essays
  • Good Essays

    Bis Midterm Sheet

    • 1467 Words
    • 6 Pages

    Database: A data base is a self-describing collection of integrated records. Bytes (character of data) are grouped into columns. Columns are also called fields. Columns or fields, in turn, are grouped into rows, which are also called records. The collection of data for all columns is called a row or a record. A group of similar rows or records is called a table or a file. A database is a collection of tables plus relationships around the rows in those tables, plus special data, called metadata, that describes the structure of the database. Databases are usually stored on magnetic disks.…

    • 1467 Words
    • 6 Pages
    Good Essays
  • Good Essays

    Microsoft Excel is an electronic spreadsheet program which is used to store, organize, and handle data. It is a grid that consists of rows which consists of numbers, columns which consists of letters, and cells which is the unit that is used to store data. It can also be used for graphing, sorting, and filtering data. (About.com Spreadsheets, 2012)…

    • 828 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Array Structure Proposal

    • 574 Words
    • 3 Pages

    An array is a variable that holds multiple values of the same kind. Nearly every…

    • 574 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    PT2520

    • 1600 Words
    • 14 Pages

    In a spreadsheet application Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Chapter 1.3 Delimited • In a delimited file, each piece of data is separated from the others by a delimiter such as a comma or a semicolon. • Delimited files are commonly used to transfer data from one data source to another.…

    • 1600 Words
    • 14 Pages
    Satisfactory Essays
  • Good Essays

    Cells have addresses based on the row and column in which they appear. Each cell…

    • 2650 Words
    • 11 Pages
    Good Essays
  • Satisfactory Essays

    visual basic

    • 8352 Words
    • 34 Pages

    Set oMatches = oRe.Execute(inpStr) ' Get the first item in the Matches collection. Set oMatch = oMatches(0) msgbox typename(oMatch) ' Create the results string.…

    • 8352 Words
    • 34 Pages
    Satisfactory Essays
  • Good Essays

    Learn Excel

    • 753 Words
    • 4 Pages

    Table_array (Required): Two or more columns of data. Use a reference to a range or a range name. The values in the first column of table_array are the values searched by lookup_value. These values can be text, numbers, or logical values. Uppercase and lowercase texts are equivalent. You cannot have duplicate values in the leftmost column of the lookup range. Page 2 of 15 MS Excel Advanced Formulas 9/7/2010:mms…

    • 753 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Assingment2

    • 906 Words
    • 3 Pages

    A designer have to determine whether the maintaining the index and the additional space consumed by the index is worth in order for the performance gain you get from the queries that use the index.…

    • 906 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Steven Roman Ron Petrusha Paul Lomax Publisher: O 'Reilly First Edition August 2001 ISBN: 0-596-00092-8, 654 pages Need to make sense of the many changes to Visual Basic for the new .NET platform? VB .NET Language in a Nutshell introduces the important aspects of the language and explains the .NET framework. An alphabetical reference covers the functions, statements, directives, objects, and object members that make up the VB .NET language. To ease the transition, each language element includes a "VB .NET/VB 6 Differences" section.…

    • 115483 Words
    • 462 Pages
    Satisfactory Essays

Related Topics