Visual Basic.NET
  Home arrow Visual Basic.NET arrow Programming Fundamentals Using VBA
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Programming Fundamentals Using VBA
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 16
    2005-07-28

    Table of Contents:
  • Programming Fundamentals Using VBA
  • Creating Procedures
  • Declaring Variables
  • Constants
  • Control Structures
  • The ElseIf Structure
  • Do Loop
  • Arrays
  • Dynamic Arrays

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Programming Fundamentals Using VBA
    (Page 1 of 9 )

    This article will provide you with a chance to study the fundamentals of programming, with specific reference to the syntax of the VBA language. Variables and arrays will be discussed in detail. This article is excerpted from chapter six of the book Access VBA Programming, written by Charles E. Brown and Ron Petusha (McGraw-Hill/Osborne, 2004; ISBN: 0072231971).

    In Chapter 5 you learned about the VBA environment by looking at its structure, concepts, and editor. In this chapter, we are going to study the fundamentals of all programming while, at the same time, examine the specific syntax of the VBA language. We are going to review concepts from Chapter 5 and study them in greater detail, beginning with a review of the places where the code is stored and the types of blocks it is stored in. While discussing that, we will visit the subject of variables in greater detail. It is difficult to talk about variables without discussing a special type of variable called an array.

    We are also going to look at some of the built-in tools that VBA gives you to make your job easier. We will conclude our discussion by looking at the various types of programming structures and how they are used in a VBA environment.

    Programming Fundamentals

    As stated in Chapter 5, VBA code is written and stored within modules. Recall that there are two basic types of modules: those associated with forms or reports, and a general module for holding procedures that is applicable to the whole project.

    There is one other type, called a class module, which contains code associated with an object. We have discussed modules already in the previous chapters and will be referring to them throughout the rest of the book.

    Before you can write VBA code, you need to be able to create the module. Since form or report modules are created through their respective forms and reports, we will focus on creating standard modules here.

    Creating Standard Modules

    There are a couple of different ways of creating a standard module. The easiest way is to use the Modules category of objects right in the Database window, as shown in Figure 6-1. All you need to do is click on New and you are taken to the VBA Editor with a module created, as shown in Figure 6-2.

    VBA assigned your new module a temporary name of Module1. You will probably want to give it a more descriptive name. This can be done from the Properties window of the VBA Editor or directly in the Database window.

    As an example, in the VBA Editor, highlight the name Module1 in the Properties window, as shown in Figure 6-3, and rename it. You can call it myFirstModule. Once you have changed it in the Properties window, the name is changed in the Project window as well as in the Database window in Access (under the Modules category).


    Figure 6-1.  The Modules category selected in the Database window  

     
    Figure 6-2.  The VBA Editor with a module open

    In addition, you should click on the Save icon in the toolbar. You will be prompted to confirm the name, as shown here:

     

    Now you can confirm that the name has been changed in the Project window (Figure 6-4) and the Database window Figure 6-5).

     
    Figure 6-3.  The Name property


    Figure 6-4.  Project window after renaming the module 


    Figure 6-5.  Database window after renaming the module

    NOTE


    You can also change the name in the Database window by right-clicking it and selecting the Rename menu command.

    More Visual Basic.NET Articles
    More By McGraw-Hill/Osborne


     

    Buy this book now. This article is excerpted from chapter six of the book Access VBA Programming, written by Charles E. Brown and Ron Petusha (McGraw-Hill/Osborne, 2004; ISBN: 0072231971). Check it out at your favorite bookstore today. Buy this book now.

    VISUAL BASIC.NET ARTICLES

    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic
    - Manipulating Forms with the Windows Forms Li...
    - Basics of the Windows Forms Library
    - Forms, Controls, and Other Useful Objects
    - Implementing OOP to Develop Database Oriente...
    - Using Themes and Skins for Personalization w...
    - A Deeper Look at Personalization using Visua...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway