VB in 5 Days

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 38

Visual Basic

Visual Basic:

Day 1: Overview Of Development Process


Overview Of Development Environment
Visual Basic Code Basic

Day 2: Introduction To Visual Components


Intrinsic Controls
Shipped Controls
Debugging tools

Day 3: Data Access Techniques


ADODC
ADO
Data Environment
Day 4: Understanding OOPS
Class Module
ActiveX Controls
ActiveX Servers

Day 5: ActiveX Technology Behind the Screen


Application Architecture
N-tier Architecture

References:
1)Guide to Visual Basic - Peter Norton
2)Visual Basic study guide- Michael McKelvy
3)Doing Objects with VB- Debora Kurata
4)ActiveX Technology with VB- Dan Appleman
Overview Of Development Process

User Interface
Instruction Set

Application Areas

Small to Medium size

Database Applications
Front end Tool
ActiveX component Creation tool
Internet Intranet Applications

Windows Programming Language

Windows
Events
Messages
Features Of Visual Basic:

Event Driven Model


Object Oriented Design
Complete Development System
Extensibility through ActiveX Tech.
And Transaction Server

Development Process:

Design and Build User Interface


Write Code For the Expected Events
Test and Debug
Convert to Run Time
Prepare for Distribution
Overview Of Development Environment

Integrated Development Environment


Form Designer
Tool Box
Tool and Menu bars
Project Explorer Window
Property Window
Code Editor
Object Browser
Immediate Window
Local Window
Watch Window

SDI / MDI

Docking
Types of files :
*.frm Form
*.cls Class
*.bas Standard
*.res Resource
*.Doc ActiveX Document
*.Ctl /*.OCX ActiveX Control
*.dsc Active Designer

Project Properties:
General
Type of Project
Startup Object
Make Page
displayable info
Compile
Optimizing the Performance
Component

Debugging
Code Editor

Project Name Module Name Object List Procedure List

line continuation character _ and &

Tools-Option
Overall Appearance
Color coding for keywords,Identifier,Comments
Automatic Word Completion (ctrl+spacebar)
Auto Indent
Auto Syntax Check
Require Declaration
Auto List Members
Auto Quick Info
Auto Data Tips
Visual Basic Data Types

Data Type Storage Requirement Range

Byte 1 byte 0 to 255


Integer 2 bytes -32768 to 327676
Long 4 bytes -2,147,483,648 to 2,147,483,648
Single 4 bytes -3.402823E38 to -1.401298E-45
1.401298E-45 to 3.402823E38
Double 8 bytes -1.79769313486232E308
-4.94065645841247E-324
Currency 8 bytes very high
Boolean 2 bytes True or False
Date 8 bytes Jan 1,100 to Dec 31 9999
Object 4 bytes Reference to Object
String Variable 0 to 2 billion
Variant Variable
Declaring Variables

Naming Convention
Must begin with a letter of the alphabet
Must consists only letters digits & underscore
can be as long as 255 chars
can’t be duplicate in same scope

Implicit and Explicit Declaration

Types of Declaration
Dim
Static
Public
Private
Keyword variable_name as DataType
Declaring Arrays

Dim Array_name(lowerbound to Upperbound) as Data Type


Dim Array_name() as Data Type
Redim Array_name (lowerbound to Upperbound)
Redim Preserv Array_name (lowerbound to Upperbound)
Ubound(Array_name)
Lbound (Array_name)

Using Constants

Const const_name as Data_type=value

User-Defined Data Types

Type type_name
element_name as Data_Type
End Type

var_name as type_name
Subroutines and Functions

pass by value
pass by reference
Optional arguments
Named argumnets
Calling
Call procedurename(para1,,,,)
procedurename para1,,,,

Program Flow
Conditional Branching
if then
If then else
if then elseif endif
Select case
case 1
case else
end select
Looping

For Next
Exit For

Do Loop Until
Do Loop While
Do While Loop
Do Until Loop
While Wend

Compiler Directives
#Const Indentifier=value
#if #then #Else #end if
What Next?

Exercise:

Set up the environment


Try to explore the development Process
Before Start:

Objects ,Attributes,Operations

Attributes- Properties Operations-Methods


Events -methods Objects-Components

Design time
Run time

Setting properties,writing & invoking Methods


General Properties :
Related to Size
Related to Placement
Related to Visibility
Tab sequence
Name

Form:

Properties Events
Caption Initialize
Control box Load
Window State Activate
Icon Deactivate
Start Up Position Queryunload
Unload
Terminate
Show
Hide
Controls
Label lbl Display text
Text box txt Display editable text
Frame fra Border or Container
Command Button cmd Button for triggering
Check box chk Selection(optional)
Option button opt Selection(compulsory)
List Box lst Display a list of value
Combo Box cbo Display drop down list
Scrollbar(h/v) (h/v)sb Scrolling
Timer tmr Trigger timed events
Drive List Box drv Drive selection
Directory list box dir Directory selection
File list box fil File slection
Image box img Display images
Picture pic Display images
Data Control dat database connection
OLE control ole OLE container
Label
Properties caption Events --
Wordwrap
Text box
Properties Text Events Validate
MaxLength Change
Multiline
Button
Properties Caption Events Click
Style
Cancel
Default
List
Properties Multiselect Events List click
Column Methods Clear
Itemdata AddItem
List List
ListIndex
Check Box
Properties caption Events Click
value
Style
Frame
Image
Picture
Scroll bar
Properties Value Events Change & Scroll
Timer
Properties interval Events Timer
Drive list
Properties Drive Event Change
Directory list
Properties Path Event Change
Parent
File List
properties File name Event Change
Parent
Path
Shipped Controls
Common dialog control Properties Method Action
File Show---
Font
Microsoft windows common controls
Statusbar Progressbar Imagelist
TabStrip Imagecombo
Stausbar

Panels text,caps,num,ins,scrl,date,time,KANA
key
Minwidth
Autosize no,spring,contents
.panel(index)
.panels.add
Progress bar
min,max,value (similar to scroll)
ImageList
key,picture,tag
Add,remove,clear
Tool bar
ImageList DisabledImageList HotImageList
Boredrstyle Apperance TextAlignment Style

Buttons
key,style,Image
Style default,check,buttongroup,seperator
placeholder,dropdown.
tooltiptext

Treeview Control

Style 0 to 7
Node
.Nodes.add relative,relationship,key,text,image,selected image
relative key value
relationship tvwChild
Children,child,parent,root
List view control

View , ColumnHeaders
data addition
Dim lst As ListItem
Set lst = ListView1.ListItems.Add(, , "Jackson")
With lst
.SubItems(1) = "test2"
End With
Menu bar
menu editor

Popup menu
visible property false
No necessity of additional menu

Miscellaneous control
Calendar
Date time picker
Image combo

Debug
Msgbox
Debug.print
Break point
Stepinto
Stepover
Stepout
Local window
What next?

Day 3

Data Access techniques

Universal Data Access Model

OLE DB technology
High Speed
Low Memory
Ease of use

ADODC
abstraction over ADO

type of connection
Security
Record source

Data consumers data source data field


Types of cursors
Static Dynamic/Keyset

Methods
addnew
delete
move
update
find
Properties
eof/bof

DataList/DataCombo

Source Destination
Bound column List Field
Data field Row Source
Data Source
ADO Object Model

Connection

Command

Parameters parameter
Errors error

Recordset

fields field

properties property
Connection RecordSet
Connectstring Activecommand
provider Activeconnection
Datasource Open/close
Mode dml features(Batchupdate)
cursor location Disconnected recordset
open Lock
executeQuery sqlsatement Cursortype(Dynamic,static--)
begintrans Fields
committrans
rollbacktrans
OpenSchema

Command Parameter
ActiveConnection Attributes
command type Direction
commandtext Name
execute value
Createparameter
parameters
Append
Multiple Recordset

Some Additional features :

Data Environment Designer


Connection

Command
child command

Dataconsumers
data source
data member
data field
Data Report

Data source
Data member
show
Are you comfortable?

YES NO
Levels of coding

event level code Form level code


Standard Module Class Module

Event code Form


specific to event Specific to form available to
components in this form
Standard Module Class Module
common operations specific object details like
throughout the project attributes,Operations& events

Properties get let/set

Event declare & raise Method

Withevents
Interfaces,polymorphism and inheritance

implementation
interface

Interface inheritance in visual basic

delegation for implementation inheritance.

ActiveX :

ActiveX control ActiveXDLL ActiveXEXE ActiveXDoc

Interactive control that can reside on any form


compiled as dynamic link library
compiled as exe and can work in stand alone mode
usable in webenabled environment
Create a component
Add the required properties(custom interface)

Set project property as ActiveXDLL


Do all the work as if it is standard exe
Add one more project as standardExe
Create one instant of the Activexdll
Test its use

ActveXexe all features are same


except it also run as standalone application
Component Object Model

Common way for applications to access & perform operations


on objects
A mechanism to keep track of object usuage
A standard error reporting mechanism
A mechanism to exchange the object
A way to identify objects and to associate objects with application
who understand these objects

Identification of objects
UUID/GUID/CLSID/IID for unique identification
Object Presentation
Object Marshalling
Compound Documents
Ole Automation
InterFace Contract
GUID
The order of the functions
Parameters of the function
Return values
operation that the function performs
Interfaces
Iunknown AddRef,Release,QueryInterface
Idispatch GetTypeInfoCount,GetTypeInfo
GetIdsOfNames,Invoke
Early binding
Late binding
addRef
Iunknown Release
QueryInterface
Gettypeinfocount
IDispatch GetTypeinfo
GetIds
Invoke
Dual Mymethod
Within Application Within ActiveXDLL WithinActivexEXE

AxtiveXDll

Registering make dll/run/use regserv32 utility


Designtime ProgramID-clsid-dll(registery)-typeLib
Runtime clsid-dll-InterfacePointer

ActiveXExe
Registering same as above
Design time same as above
Run time launch the exe

Trade offs of ActiveX


ClassesExcellent performance,No registration
Duplication of code,Recompiling of code
ActiveXDll Code can be easily shared among application
Excellent performance,easy maintenance,reusable
problem of compatibility,multithreading not possible
Complex Deployment and distribution
ActiveX EXE
Separate thread,Useful in standalone mode
performance is worse,System overhead,

Instancing:
Private
PublicNotCreatable
SingleUse
GlobalSingleUse
MultiUse
GlobalMultiUse
Application Architecture:

File Server based :

Services Model Based Architecture:


Data Services Business Services User Services
reading & writing business rules data display
to database (DM) implementation & validation

Two Tier Architecture

Fat Client - server


(User Services+Business Services) (Data Services)
Client - Fat Server
(User Services) (Business Services+ Data Services)
Direct manipulation,Limited scalabilty,Limited reuse

Three Tier Architecture(N-tier)


partitioning of Services
sub partitioning of service.
Microsoft Transaction Server

Thread Management

Object Instance Management

State Management

Resource Dispensers

Transaction Management

Security Management

You might also like