Return to IFS 110 class Notes Menu!

 

Project 4
Menus, Data Controls, Common Dialogs, and
General
Procedures

Visual Basic Capabilities

Project 4 Outline

Common Database Terms

Geography Database Viewer

Getting Started

Creating the Interface

Note: common dialog control is not visible at run-time

Adding Label Control Array

Control Array Continued

Example: Label1(0) can have a caption and other property settings different from Label1(1)

Label Array Properties

Adding Common Dialog Control

Adding Data Control

Note: A form can contain more than one data control, and generally one data control exists for each database table accessed by the application

Geography Database Viewer
Data Control

Creating Menus

Note: When a menu is open, you press only the access key of a command (not the ALT key.)

Example: Exit (press only the x key)

Menu Concepts

Setting Properties (steps)

Setting Properties of Form

CommonDialog Control Properties

Data Control Properties

Setting Properties of Data Control

Setting Properties
Data-Aware controls

Setting Properties
Data-Aware controls

Setting Properties
Data-Aware controls

Writing Code (table 4-2 VB 4.38)

Geography Database Viewer code tasks

QueryUnload Event

Select Menu Subroutines

Code statement form

Example: Data1.Recordset.MoveNext

Coding EOF statement

Data1.Recordset.MoveNext
If
Data1.Recordset.EOF = True Then Data1.Recordset.MoveFirst

Note: If the MoveNext command causes the current record to move past the last record, then the first record in the database becomes the current record

MouseUp Event

If Button = 2 Then PopupMenu mnuOptions

Using Font Property

Code :

Label1.FontSize = CommonDialog1.FontSize

For...Next statement (loop)

For counter = start To end (header part)

[statements] (repeated)

Next (terminator part)

With Statement

Syntax:

With object

[statements]

End With

Potential Problem

Solution: - write code statements that adjust form's size (Height and Width) and controls' locations (Top and Left)

For...Next and Arrays

Coding:

For X = 0 To 5

With Label1(X)

.FontName = CommonDialog1.FontName (etc)

End With

Next

General Procedures

General Procedures

Advantage: - when multiple events execute similar code, it is more efficient to put code in a general procedure and then activate the general procedure from the appropriate events
Example of call: - ToggleView mnuName, 1

General Procedures

Check Marks in Menus

Code: mnuFlagshow.Checked = True

Project 4
Menus, Data Controls, Common Dialogs, and
General
Procedures
END

Program Creating a Database Viewer Application Requirements

Return to IFS 110 class Notes Menu!

Click for Printer Version