Sie sind auf Seite 1von 14

Visual basic evolved from BASIC(Beginners' All-purpose Symbolic Instruction Code).

The BASIC language was created by Professors John Kemeny and Thomas Kurtz of Dartmouth College in the mid 1960s Visual basic is a windows programming language that has been developed by Microsoft Corporation Features Vb is user friendly tool It is platform dependent. It is simple and easy to develop GUI application Vb is called as event driven programming. it means that the code does not follow a predetermined path it executes different code sections in response to events It is also called as RAD tool-rapid application development tools. It is also called as IDE integrated development tool. it is basically used to describe the interface and environment where we develop, run, test and debug applications.

. visual basic

projects

forms

objects

properties methods ,events

Object to describe all the forms and controls that make a program . Properties characteristics such as size, caption, color etc Methods the action that an object can perform Events action recognized by form or control i.e pressing a key, clicking a mouse

Vb provides 9 windows
Object window : it is purely meant for designing purpose Property window : it is used to set the character or name Code window :it is editor where we can write code Project explorer window : it is used to navigate from one form to another form Immediate window : we can execute built in functions and also used to debug
the errors

Local window : Watch window :


Tracing the values

Form layout window : it decides where the form should


Object browser : it contains all the objects

A variable is an area that stores value during program execution.

Variable naming convention:


It must begin with a letter It cant contain an embedded period, spaces or other punctuation character It cannot exceed 255 characters Data types: Vb recognizes the following six types of variables Numeric String Boolean Date Object Variant

Data type
Byte
Boolean Integer

no of bytes
1
2 2

range
0 to 255
true/false -32768 to 32767

String
Long Single

1byte/character (64kb)655000 bytes


4 4 -2gb to 2gb

Double
Decimal Date

8
14 8 1 Jan 100AD to 31 dec 9999 8 supports 4 decimal points to right and 15 to the left reference to any object 16 bytes for numeric data 22 bytes +Len (string) for character data

Currency
Object Variant

The keyword dim or static are placed before the variable name and data types Dim name as string

The local variables are created and exist only as long as the procedure is executing
Static amt as integer

Static variables are used with in the procedure level and they retain their values even after the procedure has finished executing

Procedures
Vb completely depends on procedures. the code in a vb application lives in a containers called modules. the code within the modules is composed of procedures

1. Sub procedure: it is a procedure which does not return a value Syntax:


<private|public>sub <procedure name> Statements End sub

2. Function procedure : it may take the parameter and ultimately return the
value

Syntax:
<private|public>function <functionname>(argumentlist) as datatype Statements End function

3.Property procedure: it may return or may not return value Syntax:


<private|public>property<let||get|set>propertyname(argument list)[as data type] Statements End property.

Let assigning Get returning Setreference 4. Event procedure: it will never return a value. Syntax:
Private sub<controlname>_<procedurename>[argument lists] statements End sub

Message box : it is an alert which draws the attention of the user to work with it Syntax when it is function msgbox(message ,[icon style,title]) eg: n = MsgBox("r u sure?", vbQuestion + vbYesNo,sure) Syntax when it is procedure Msgbox,message,[icon style, title] Eg: MsgBox "welcome to vb programming", vbInformation, "welcome Input box : this is used to input the data i.e by passing messages Syntax Inputbox(prompt message, title of input box])

Conditional Operators
Conditional operators are very powerful tools, they let the VB program compare data values and then decide what action to take, whether to execute a program or terminate the program and etc.
Operator = > < >= <= <> Meaning Equal to More than Less Than More than and equal to Less than and equal to Not Equal to

Logical Operators
Operator And Or Xor Not Meaning Both sides must be true One side or other must be true One side or other must be true but not both Negates truth

Control flow or Decision making statements


Control structures allows to control the flow of the programs execution depending up on the test condition
1. simple if if condition then statements end if 2. if condition then statements else statements endif

3. if condition then statements elseif statements else statements endif 4. select case expressions case value 1 statements case value 2 statements case value 3 statements case else statements end select

Iterative control structures or looping constructs


The statement will be executed repetitively as long as It satisfy the condition

while condition statements wend do while condition statements loop do statements loop while condition

do

statements loop until condition

for <variable>=<starting value> to <end value>[step value] statements next <variable> for each <variable> in <form> if typeof <variable> is <control name> then statements end if next <variable>

Das könnte Ihnen auch gefallen