WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

51
WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC BY V. V. SUBRAHMANYAM

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

Page 1: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

BY

V. V. SUBRAHMANYAM

Page 2: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

Working with files

Visual Basic File System Controls

DriveList Box

DirList Box

FileList Box

Page 3: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 4: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

DirList Box Control

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

Directories in the current drive

Page 5: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 6: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 7: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC
Page 8: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC
Page 9: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC
Page 10: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 11: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 12: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 13: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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.

Page 14: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 15: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC
Page 16: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC
Page 17: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC
Page 18: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC
Page 19: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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.

Page 20: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 21: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

MDI Application

An application can have only one MDI form

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

modules

Page 22: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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.

Page 23: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

Three categories of databases

Visual Basic recognizes 3 categories of databases

Visual basic database

External databases

ODBC databases

Page 24: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

Creating a table

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

Page 25: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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.

Page 26: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC
Page 27: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 28: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 29: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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.

Page 30: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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.

Page 31: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

`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.

Page 32: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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.

Page 33: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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.

Page 34: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

ImageList control

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

Page 35: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

MSFlexGrid control

This displays and operates on data in a table form

Page 36: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

Toolbar Control

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

Page 37: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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..

Page 38: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

Treeview Control

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

Page 39: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

ActiveX Data object

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

Page 40: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

Benefits of ADO

Ease of use High speed Low memory overheads Small disk footprint

Page 41: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

ADO support

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

Page 42: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

BUG

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

Page 43: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

Debugging

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

Page 44: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

Types of Bugs

Errors of syntax Logical errors Runtime Errors

Page 45: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

Debugging Methods

The Message box Debug.print Debug Toolbar Error Handler

Page 46: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 47: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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

Page 48: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

Debug Toolbar

To begin debugging, Debug Toolbar is required.

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

Page 49: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC
Page 50: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC
Page 51: WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC

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.