VB 6 Database Programming - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

VB 6 Database Programming

Description:

Encapsulate code in VB Class Module. Reuse the class with any form ... Agree to all the doomsday warnings. Open VB and add components. ... – PowerPoint PPT presentation

Number of Views:246
Avg rating:5.0/5.0
Slides: 17
Provided by: janehutt
Category:

less

Transcript and Presenter's Notes

Title: VB 6 Database Programming


1
VB 6 Database Programming
  • Chapter 7

2
Chapter 7 Tutorial
  • Read and Complete all of Chapter 7

3
Class Modules
  • Code Reuse
  • Encapsulate code in VB Class Module
  • Reuse the class with any form
  • Add a few lines of code to create the class
  • Set a few properties
  • Example we have coded a Data Entry
    (Maintenance) Program for a table in a database
    so lets reuse the same code for any table in any
    database
  • Thus the array and loop concepts

4
What is a Class? An Object?
  • A Class is a template for something we wish to
    build
  • Like a blueprint to build a house (instructions
    only)
  • An object is an instance of the class
  • The completed house (using the blueprint) is an
    object
  • We have instantiated an object from the class

5
PIE (OOP Technology)
  • Polymorphism
  • Inheritance
  • Encapsulation

6
Polymorphism
  • We can call a method or a property irrespective
    of the particular ways that a specific object
    implements them
  • Different types of objects can perform the same
    kind of action (in different ways)
  • Classes have properties and methods

7
Inheritance
  • A child object can inherit the functionality of a
    parent object
  • An object could share methods common to other
    objects
  • An object could contain methods specific to their
    own type
  • Create a parent object, then use it as the basis
    for a new object

8
Encapsulation
  • Information about the implementation of an object
    is hidden within the class
  • Details of how it works are transparent to the
    outside world

9
VB and PIE
  • Classes we can create in VB support the concepts
    of Polymorphism and Encapsulation only

10
VB Class Builder
  • Handy tool for building a class module
  • Add Properties
  • Add Methods
  • only shows Public Methods if you re-enter the
    Class Builder
  • Creates (Private) Variables for each property in
    code
  • Creates (Public) Property code to assign values
  • Get Read value from variable
  • Let / Set Write (assign) value to variable

11
Creating a Class Module
12
Properties
  • Data Control Caption (Find)
  • Buttons Record Source (Find)
  • DBName Match Field (Find)
  • FormName
  • Label to Update (Record _ of _ )
  • Progress Bar
  • Record Source
  • Tag

13
Methods
  • Process Cmd Build Criteria (Find)
  • Lock The Controls
  • Navigate Buttons
  • Update Buttons
  • Update Label

14
P 306 Main Form_Activate
  • Add the Boolean variable code to prevent the
    Activate from occurring more than once Refer to
    Book Errata approx. page 11
  • Note the following corrections in the
  • With myDataClass code
  • .LabelToUpdate lblRecordCount quotes
  • .LockTheControls(True) add this
    line to lock text boxes instead of code in
    errata
  • Make sure it is a Public Sub not Private

15
P 314 cmdFind Routine
  • Note error
  • Dim sResult As String only 1 letter
    el

16
P 330 339Parent / Child Form
  • Adding the Data Bound Grid Control at home
    (thanks to Paul Duncan)
  • On the VB6 CD or Visual Studio 6 CD navigate to
  • Common -gt Tools -gt VB -gt controls
  • CtrlA to select entire contents of this
    directory
  • Copy all files into C\Windows\System
  • Run 2 commands from Start Menu
  • regsvr32.exe dbgrid32.ocx
  • regedit dbgrid.reg
  • Agree to all the doomsday warnings
  • Open VB and add components. If Data Bound Grid
    Control is still not there, select Browse and
    select dbgrid32.ocx from C\Windows\System
Write a Comment
User Comments (0)
About PowerShow.com