WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

Post on 11-Jan-2016

33 views 2 download

description

WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC. BY V. V. SUBRAHMANYAM. Working with files. Visual Basic File System Controls DriveList Box DirList Box FileList Box. DriveList Box control. Is a drop down list box Displays the list of drives on your computer - PowerPoint PPT Presentation

Transcript of WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

BY

V. V. SUBRAHMANYAM

Working with files

Visual Basic File System Controls

DriveList Box

DirList Box

FileList Box

DriveList Box control

Is a drop down list box Displays the list of drives on your

computer The change is recorded in Drive

property of the DriveList Box

DirList Box Control

It is a Drop down list box Displays the hierarchical list of

Directories in the current drive

FileList Box

It is a Drop down list box Displays all files in the current directory

or folder and also allows the user to set up search criteria for files

Advantages of file system controls

These three controls used together can create an elegant interface that will allow the user to locate a file on his computer

Private Sub Dir1_Change()

File1.Path = Dir1.Path

End Sub

Private Sub Drive1_Change()

Dir1.Path = Drive1.Drive

End Sub

Private Sub Text1_Change()

File1.Pattern = Text1.Text

End Sub

File functions ChDrive - Changes the current logged

drive ChDir - Changes the default

directory MkDir - Creates a new directory RmDir - Deletes a directory Name - Renames a file

Contd…

Kill - Deletes a file FileCopy - Copies a file from src to des FileDateTime – Returns the date and

time when the file was modified GetAttr - Returns the attributes of a

file as an integer value SetAttr - Sets the attributes of a file

Menus

Contains a no. of options, logically organized and easily accessible.

In VB Menus can be created using the Menu Editor

Menu is tied to a form.

Menu Conventions

Keep menu captions short and simple Follow the Windows conventions while

naming and ordering the menu items Keep the list of menu items short Use separators to logically group menu

options Provide necessary keyboard shortcuts

Multiple Document Interface (MDI) MDI was designed for applications

which need to show more than one document(multiple documents) at the same time, with each document displayed in its own window.

Why MDI forms?

MDI form acts like a container for the other forms in the application

Most of the control buttons and code for the various forms can be shared

Reduces the no. of controls

MDI Application

An application can have only one MDI form

One or more MDI Child Form(s) Optionally independent forms and

modules

Data Base It is a collection of records stored in

tables. Information is stored in tabular form and

is called a table.

Columns Fields

Rows Records The collection of the tables is called as

database and are stored in a file.

Three categories of databases

Visual Basic recognizes 3 categories of databases

Visual basic database

External databases

ODBC databases

Creating a table

You can create your own tables using– DAO(Data Access Objects)– Microsoft Access and others– Visual Data Manager

Visual Data Manager

Visual Data manager makes the job of table creation and modification very simple.

This can work with MS-Access, Dbase, Paradox and text files also.

Data Control

Establishes a connection to a database Returns a set of records from the

database Enables you to move from record to

record Enables you to display and manipulate

data from the records in bound controls

Properties to be set to Data control Two properties to be set at runtime or

design time are:

DatabaseName: Specifies the name of the database that must be opened

RecordSource: Specifies the name of the table(s) of the database from which the data has to be extracted

Data-Aware Control

It is the control that provides access to a specific field in a database through a data control.This can be bound to a data control through its data source and data field properties.

DBlist, Dbcombo and Dbgrid

These controls are all capable of managing sets of records when bound to a Data Control. All of these controls permit several records to be displayed or to be manipulated at a time.

`Object Linking and Embedding(OLE) To create an application that can

display data from many different applications and enables the user to edit that data from with in the application in which it was created.

OLE DB It is defined as a new low-level interface

that is part of the Universal Data Access platform.

It is general purpose set of interfaces designed to let developers build data access tools as components using the COM.

Additional Controls Sstab control Provides an easy way of presenting

several dialogs or screens of information on a single form, using the same interface seen in many commercial Windows applications.

ImageList control

This control acts like a repository of images for the other controls

MSFlexGrid control

This displays and operates on data in a table form

Toolbar Control

This is used to create a toolbar for the application, just like Toolbars for applications like Word or Excel or others.

Statusbar Control

This control holds up to a maximum of sixteen panels or frames each of these panel given different types of information like time, microhelp, status of a key etc..

Treeview Control

To display the data as a hierarchy. It displays the drives, directories, subdirectories and files in the form of a hierarchy.

ActiveX Data object

This enables the client applications to access and manipulate data in a database serer through any of the OLE DB providers.

Benefits of ADO

Ease of use High speed Low memory overheads Small disk footprint

ADO support

ADO support key features for building client/server and Web-based applications.

BUG

The error or the problem occurred in the system is called as a bug

Debugging

The process of finding out and removing the error is called debugging.

Types of Bugs

Errors of syntax Logical errors Runtime Errors

Debugging Methods

The Message box Debug.print Debug Toolbar Error Handler

Message Box To display the state of values that have

been assigned to a variable

Dim I as integer

For I = 1 to 20 step 4

MsgBox I

-----

Next I

Debug.print

The debug object will send the output to the immediate window.

Dim I as integer

For I = 1 to 20 Step 4

Debug.print I

Next I

Debug Toolbar

To begin debugging, Debug Toolbar is required.

To bring up, right click the toolbar and select Debug from the pop-up menu

Error handler

It is a routine that traps errors and directs the user or the program to perform a certain task to overcome the error.