AccessVBA Programming for Beginners Class 1 - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

AccessVBA Programming for Beginners Class 1

Description:

VBA = Visual Basic for Applications. Visual Basic is a stand ... VB for Applications = Visual Basic that is 'customized' to work with Access, Excel, Word, etc. ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 17
Provided by: patric126
Category:

less

Transcript and Presenter's Notes

Title: AccessVBA Programming for Beginners Class 1


1
Access VBA Programmingfor Beginners - Class 1 -
  • by
  • Patrick Lasu
  • p_lasu_at_lycos.com

2
Class 1 - Overview
  • What is VBA?
  • History of VBA
  • Event-Driven Programming
  • Helpful Hints
  • Code Window
  • Help in VBA
  • Subs and Functions
  • Variables and Constants

3
What is VBA?
  • VBA Visual Basic for Applications
  • Visual Basic is a stand-alone programming
    software that is event-driven
  • VB for Applications Visual Basic that is
    customized to work with Access, Excel, Word,
    etc.
  • Excel has Sheet objects
  • Word has Document objects
  • Access has Data objects

4
Brief History
  • Visual Basic for Applications (VBA) is derived
    from Visual Basic (VB)
  • VBA was fully integrated into Office 97 except
    Outlook
  • Prior to that, there were Macros
  • Before VB, there was QBasic (Microsoft Products)
  • Based on BASIC (Beginners All-purpose Symbolic
    Instruction Code) programming language

5
Brief History
  • Languages based on BASIC got a bad rap because
  • They were considered slow
  • Need a software platform to run

6
Brief History
Software Platform for VB
VB
Windows
CPU
7
Brief History
Software Platform for VBA
VBA
Access
Windows
CPU
8
Event-Driven Programming
  • What is it?
  • Code does not execute until an event is happening
  • Analogy You answer the phone when it rings
    instead of picking up the receiver every 2
    seconds to find out if somebody is calling.
  • Program is Form-centric
  • Code uses forms, which breaks up code into
    smaller portions, and gives the user flexibility
    when entering data.

9
Helpful Hints
  • There are at least 3 ways of accomplishing the
    same task when coding
  • Good Code It works
  • Bad Code It does not work
  • Strive to make your code as short as possible
  • It saves time when typing code
  • Runs faster
  • Easier to debug
  • Save Often (Ctrl S)

10
Variables and Constants
  • A variable is a storage for a value that can
    change during code execution
  • Answering Yes or No
  • A constant is a storage for a value that does not
    change during code execution
  • 3.1415, vbYes, vbRed
  • Can be changed manually
  • Going from 365 days to 360 days when calculating
    interest

11
Variables and Constants
  • There are several Data Types for Variables and
    Constants for efficiency
  • String Stores Text Patrick, 123 Main St
  • Number Stores Numbers - 1, 2, 3,..., 3.14
  • Boolean Stores True/False
  • Date Stores Date
  • Currency Currency format Dollar, Yen
  • Variant Stores Anything
  • And there are many more!!!!

12
Variables and Constants
  • We will work mostly with (for starters)
  • Strings
  • Integers (whole numbers, no decimals)
  • Boolean
  • Variant

13
Variables and Constants
  • Naming convention for Variables
  • Strings Starts with str
  • strFirstName
  • Integers Starts with int
  • intCount
  • Boolean Starts with bln, bol, bool
  • boolExit
  • Variant Starts with var
  • varAnyValue

14
Variables and Constants
  • A variable needs to be declared
  • Syntax Dim variablename As type
  • Dim Dimension (make space for it)
  • variablename Ex strFirstName
  • As type Optional, Ex As String
  • Dim strFirstName As String

15
Variables and Constants
  • Naming convention for Constants
  • Well do it in next class!!!!
  • Well also talk about Public and Private
    variables and scope/visibility
  • Why not making all variables Variants
  • And much more

16
Review
  • It works!!! Good Code
  • Code is short and sweet Even better
  • There are at least 3 different ways of coding
  • Save Often
  • Use the Help files
Write a Comment
User Comments (0)
About PowerShow.com