Unit-1- Notes FOR Visual Basic PART 1 PDF

Title Unit-1- Notes FOR Visual Basic PART 1
Course Visual Programming
Institution Bangalore University
Pages 37
File Size 229 KB
File Type PDF
Total Downloads 46
Total Views 262

Summary

  NOTES FOR VISUAL BASIC PART 1   1 to vb What is vb? vb is a user friendly event driven and partly objected oriented programming language using which we can develop: database application. web enabled application. and variety of other window based application.   Who developed vb? vb i...


Description

NOTES FOR VISUAL BASIC PART 1

1.Introduction to vb What is vb? vb is a user friendly event driven and partly objected oriented programming language using which we can develop: database application. web enabled application. and variety of other window based application. Who developed vb? vb is developed by Microsoft in 1991 as Visual Basic 1.0. Why vb was developed? before vb window based application was being done using c and window based compiler which was a slow and tedious process. it required lots of coding. to speed up development of window based application vc++ and Microsoft foundation class were developed. but the development process was still tedious and slow. to boost development of window based application easily and fastly vb was introduced. What are the different editions of vb? there are three editions of vb:standard or learning edition: contains basic language feature and tools. professional edition: contains more feature and tools when compared to standard edition. enterprise edition: contains most advance feature and tools. the edition which we are using is enterprise edition. What are the hardware requirement to use vb? the hardware requirement are as follows:

cd-rom drive cd-rom (1 to 7 cds). first cd rom contains compilers for various languages like vb, vc++, visual foxpro, visual internet developer etc. remaining cds contains help, client server tools, samples etc. windows 9x Os. 80 to 120 mb for installation of vb. 40 mb free hard disk space for user generated program. 16 mb ram minimum ( 32 mb ram recommended) 80486 based micro processor ( Pentium 166 mhz recommended) What is Event Driven programming? when a program consists of one or more than one event procedures and those procedures accomplish the task to be done by program it is know as event driven programming. What is event? Event is any action performed by either performed by user or performed by program itself. for example mouse-click, key press, window resize etc. What is the difference between structured/procedure oriented and event driven programming Structured/Procedure Oriented

Event Driven Programming

Program consists of one or more procedure. Program consists of one or more event procedure. Programming procedure.

task

is

completed

byProgramming task is completed by event procedure.

The order of execution of procedure is more The order of execution of event procedure or less predictable. depends on user performed action.

Procedure oriented programming is notEvent driven programming is suitable for suitable for window based application. window based application.

What do you mean by IDE ? Ide stands for integrated development environment. it is collection of program allowing to compose and edit the program, test the program, run the program and debug the program.

Describe working environment of vb? Working environment of vb is compsed of many elements: title bar: where program title, project name and program mode is displayed menu bar: contains menu and related commands. tool bar: consists of icons which are short cuts to frequently used commands some toolbars are : standard, formatting etc. toolbox: on the left side toolbox appears which contains controls. form designer: appears in element(controls) are placed.

middle

where

graphical

user

interface

properties window: using this we can set properties of controls. project explorer window: displays files which make up the project form layout window: displays form-icon used to set start up position of form. immediate window: useful to test any statement or to print value of variable. What are the different modes of vb program? there are three modes of vb program: design: ( when designing form and writing code) run : when a program is running. break: when any occurred in program. What is project file? why it is needed? project file contains information about all those file which make the project. it stores location of individual file with path. when saving project it saves all files one by one inside project. when we open project it automatically opens all files which are part of project we need not to open each file one by one thus saving time. project file has extension “vbp”. What is executable file. how it is made?

to make executable file (exe) we have to go to file menu and have to select make exe. copying of exe file to another computer and running the exe file does not guarantee that the executable file will run there because a window based program depends on many different file. it better to run distributable package using package and deployment wizard. What is module? module is collection of procedures and functions corresponding to a file in disk will generate. benefits are: it provides code reusability and shariblity. avoids code repetition. testing and debugging becomes easier. type of module: form module: normally contains event procedures, other procedure and function which will be used inside the same form module. extension is .frm basic module: normally contains global variables, procedure and function which can be accessed across other modules. extension is .bas class module: contains definition of class, member function and properties. extension is .cls How to use code editor window? code editor window can be brought forward using either of these methods: select view-> view code right click on form and select view code double click on any control or on double click on form. from project explorer window select the form name and click on button view code. navigation of code editor window: control+left arrow : move one word left control+right arrow : move one word right control +home : move to beginning of code view control +end : move to end of code view home : move to beginning of line end : move to end of line

control+up arrow : move one procedure up control+down arrow : move one procedure down shift+f2: view definition of function or procedure under cursor control+shift+f2: go to last position of cursor what is documentation? why it is needed? documention of code is very necessary. using documention we can increase readability of our program. using documentation we can store addition information like: date and time of program version no. of program company for which it was created author of the code variables used and purpose algorithm of program explaination of statment documentation makes the program easily understable. in future if we are going to make modification in program it will help greatly. we use ‘(apostrophe) to write comments or rem keyword. how formatting of code is done? formatting of code make program easy to read. indentation makes easy to follow closing of control structure. different background and foreground colors, fonts, font size can be assigned to normal text, keywords etc. using tool->options>editor format tab. procedure seperator line can also be turned on to help to identify where one procedure is beginning and ending. describe environment options in vb? select tools->options->environment tab under when visual basic starts if option button selected is prompt for project: each time visual basic starts a dialog box appears which lets us select type of project. if option button selected create default project: each time visual basic starts it automatically open standard exe project. under a program starts:

if save changes: is selected when program is about to start it saves the changes made in project. if selected prompt to save changes: is selected when program is about to start it will ask to save the changes. if selected don’t save changes: it will not save the changes made in project and will run program. show templates for: we can have many templates available for use as starting point for form, mdi forms, modules etc. Describe editor options. select tools->options->editor tab. auto syntax check: if checked , when writing a statement and pressing enter check the statement for error. require variable declaration: puts ‘option explicit’ statement in module’s general declaration section which forces declaration of variable before use as in clanguage. auto list member: if checked gives popup list consisting of properties, methods supported by object. auto quick info.: if checked gives information about function parameter and data type of parameter which current function will work on. auto data tips: if checked gives list of constant which can be assigned to a variable or to parameter of a procedure or function. dim b as Boolean type b= then you will get true, false in a list auto indent: if checked starts new line just below the previous line. tab width: specify the amount of space generated by a tab key. drag and drop text editing: if checked supports drag and drop in code editor window. default to full module view: if not checked only one procedure will be visible at a time. procedure separator: if checked draws line among procedures. Describe automatic code completion feature of vb. when we have to use any object property or any method of object we have to type just a few letter of that property or method as soon as the property or method is selected from popup list we can press control+space key combination to complete the whole property or method thus saving key stroke.

2. Creating programs

What is Object? object is class variable which is composition of properties, methods and data member. object is fundamental requirement of any object oriented language. object has three characteristics: state: state of any object it defines identity of object. behaviour: behaviour of any object is decided by member functions(methods) to which object can respond. method: it is also known as member function it performs computation on data member or any kind of action. What is property? property of any object is actually member procedure which allows to set value in data member ( working as mutator) or allows to retrieve value of data member ( working as accessor). How to create program in vb? steps are as follows: first decide the controls which will be used to create graphical user interface. set properties of controls write event procedure coding. How to get print of visual basic program. save the project select file->print from the dialog box specify: under range: selection – to print selected code current module- to print current module current project- to print all modules in current project

under print what: form image- to print the image of form. code- to print code form as text- to print form as text format , resulting of printing of controls along with properties and code under setup, specify paper size, orientation of paper and printer to use

Describe controlling objects. or describe toolbox. control depend on interface which are properties,events and methods. normally there are many controls found in visual basic. some controls are activex controls which can be included in toolbox using project->component dialog. there are some control already available in toolbox which are also known as intrinsic controls or standard controls. description of standard controls are as follows: label control: it is useful to give user a prompt. text box: it is useful to input/output data for program. list box: it is useful to give list of items and user can select items from list. combo box: it is combination of text box and list box user can type new item or can select an existing item from combo box list portion. image box: can display picture picture box: can display picture. directory , drive and file list box: allows to create a dialog box to save , open file ole control: allows to use feature of other existing application. data control: useful to write data base program option button or radio button : allows to select only one of several available choices. check box: allows to select many choices of several available choices. frame: acts as container to place related controls together. command button or push button: useful to confirm action like close, open, apply etc. timer: useful to execute certain piece of code after specified interval. default property is enabled which takes true or false value. shape: useful to decorate form line : useful to draw line to decorate form

scrollbar: useful to take input/output or scrolling data. 3.Variables Procedures What is variable? variable is name given to computer memory location where we can store value and retrieve the stored value by name. variable is fundamental requirement of any programming language. rule of naming variable or identifier: variable name must start with alphabet. later on digits can be used, under score can also appear. variable name is not case sensitive only a-z, 0-9 and _ can appear in variable Name space and special are not allowed. variable name must not match with keyword we can have variable name 255 characters long name of control must not exceed 40 characters What is data type? data type of variable defines range, memory and valid operation for a variable Data type

Range

Memory

1.Byte

0 , 255

1

2.Integer %

32767 , 0 , -32768

2

3.Single !

+/- 3.4 e +34

4

4.Double #

+/- 1.7 e+308

8

5.Date

1-1-100 to 31-12-9999

8

6.string(variable) $

2 billion characters

6.string(fixed) $

7.boolean

True, false

2

8.object

Reference of any object

9. variant

Range for number is same as double Range for string is same as 2 billion characters

How to declare variable? (a) dim x as integer, y as integer or dim x%,y% (b) dim x, y as integer then x will be variant and y will be integer (c) dim b as Boolean Describe scope of variable. scope specifies the code range where value of variable is accessible. local variable: accessible inside a function or procedure. we use dim keyword to declare local variable. module level global variable: accessible inside a module but not outside from other module. we use dim or private keyword to declare module level global variable and declare it inside general declaration of module. global variable : accessible from every where. we use public or global keyword to declare global variable inside general declaration of module.

What do you mean by shadowing of variable? if global variable or module level global variable exists with name ‘a’ and a local variable also exists in a procedure or function it prevents accessing of global or module level global variable because local variable is given preference. to access value of global variable we can use modulename.globalvariable e.g. form1.a what are the operators in vb? arithmetic operator: + for addition, - for subtraction. * for multiplication \ for integer division

c=10\3 c will be 3

/ for float division c= 10/3 c will be 3.333 ^ for power e.g.

c=10^3 therefore c will be 1000

mod for modulo division c=10 mod 3 c will be 1 relation operator >,>=,...


Similar Free PDFs