UNIT - 1 VISUAL BASIC PRESENTATION FOR IT

gayathripcs 22 views 48 slides Sep 18, 2024
Slide 1
Slide 1 of 48
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48

About This Presentation

VB


Slide Content

PRESENTATION ON VISUAL BASIC

INTRODUCTION TO

UNIT -1 INTRODUCTION TO VB G etting started with VB6 , Programming Environment, Working with Forms , Developing an applications, Variables, Data types and Modules, procedures and control structures, array, working with controls : Creating and using controls, working with control arrays.

Introduction to Visual Basic 6.0  What is Visual Basic? Visual Basic is a third-generation event-driven programming language and Integrated Development Programming (IDE) first released by Microsoft in 1991 for its COM Programming Model . It evolved from the earlier DOS version called BASIC.  BASIC  means :- Beginners' All-purpose Symbolic Instruction Code . Since then Microsoft has released many versions of Visual Basic, from Visual Basic 1.0 to the final version Visual Basic 6.0. Visual Basic is a user-friendly programming language designed for beginners, and it enables anyone to develop GUI window applications easily.

History of Visual Basic Alan Cooper developed Visual Basic in 1988 and sold to Microsoft VB1 Debuts at Windows World in March 20,1991 VB2 Debuts in November 1992 VB3 Debuts in June 1993 VB4 Debuts in October 1996 VB5 Debuts in April 1997 VB6 Debuts in October 1998

Three Editions of Visual Basic The Visual Basic Learning edition is the introductory edition that lets you easily create Windows applications. The Visual Basic Professional Edition is for computer professionals and has features such as tools to develop ActiveX and Internet controls. The Visual Basic Enterprise edition is the most advanced edition and is aimed to programmers who build distributed applications in a team environment.

Types of applications created in VB 6.0 Standard EXE ActiveX EXE, ActiveX DLL ActiveX Control VB Application Wizard ,VB Wizard Manager ActiveX Document EXE, ActiveX Document DLL AddIn Data Project DHTML Application IIS Application VB Enterprise Edition Controls

Features Of Visual Basic It is a simple language. It supports Integrated Development Environment(IDE), as multiple projects can be opened. The lines of codes are Compiled Automatically with a faster compiler. It completes the word automatically. Bookmarks can be placed for quick search. Break points can be toggled easily. Drag and drop facility Clipboard and printer access. Handle fixed and dynamic variable and control arrays. Sequential random access file, and Binary access file support.

Advantages of Visual Basic The structure of the Basic programming language is very simple, particularly as to the executable code. VB  is not only a language but primarily an integrated, interactive development environment ("IDE"). The  VB-IDE  has been highly optimized to support rapid application development (" RAD "). It is particularly easy to develop graphical user interfaces and to connect them to handler functions provided by the application. The graphical user interface of the  VB-IDE  provides intuitively appealing views for the management of the program structure in the large and the various types of entities (classes, modules, procedures, forms). VB is attuned to Microsoft’s Computer Object Model(“COM”).

Starting Visual Basic 6.0

Visual Basic 6.0 Programming Window

Title bar:- The top of the window with the name of the project. The Menu Bar:- Displays the commands required to build an application. The Tool Bars:- Provides shortcut icons for quick access to the commonly used commands.

4. The Project Explorer window:- It shows the various elements of a project namely form, classes and modules. 5. The Properties Window:- Exposes the various characteristics of selected objects

While your project is running, the user can do many things, such as move mouse around; click on either button; move, resize or close your form’s window; or jump to another application. Each action by the user causes an event to occur in your Visual Basic Project. VB ignores events for which no procedures are written. Visual Basic automatically names your event procedures. The name consist of the object name, an underscore(_), and the name of event. For example: the click event of command button called cmdPush will be cmdPush_Click ().

MOUSE EVENTS KEYBOARD EVENTS FOCUS EVENTS

DATE STRING BYTE VARIANT OBJECT Data types supported BOOLEAN NUMERIC

VARIABLES

DECLARING VARIABLES EXPLICIT DECLARATION IMPLICIT DECLARARTION USING OPTION EXPLICIT STATEMENT

SCOPE OF VARIABLES LOCAL VARIABLE GLOBAL VARIABLE MODULE LEVEL VARIABLE

CONSTANTS USER DEFINED CONSTATNTS SYSTEM DEFINED CONSTANTS (PREDEFINED)

OPERATORS

ARITHMETIC OPERATORS

RELATIONAL OPERATORS

LOGICAL OPERATORS

TYPE CONVERSIONS

DATA TYPES, MODULES

Data Types A program can’t do anything until you have reserved a space in memory for the values used in it This is called declaration of variables When you declare a variable you must: Give it a sensible name Give it a data type depending on what kind of value it will hold Ask yourself will it hold just letters or whole numbers or numbers with a decimal point or dates…..etc

Basic data types Short whole numbers in the range –32,768 to 32,767 Examples: -32 or 10,000 needs 2 bytes of storage space Integer A whole number in the range –2 billion to + 2 billion Examples: 20,000,000 or -400,000 needs 4 bytes of storage

Basic data types Single Numbers with decimal places and fractions in the range -3.402823E38 to –1.401298E-45 for negative values and 1.401298E-45 to 3.4o2823E38 for positive Examples: 3·142, -700·75 Takes 4 bytes of storage Double For incredibly large or small values use a double, as a single wont provide the range or accuracy that you need Takes 8 bytes of storage Bear this last fact in mind, if you don’t need this level of accuracy, declare a single as it uses half the storage space

Variables - Naming conventions Hungarian notation is used in naming variables This is accepted as good programming practice Prefix the variable name with a 3 letter identifier to indicate the data type The variable name should be meaningful - good programmers can read the code of a program and know what it does You will need to use these conventions

Variables Prefixes sht = short dte = date int = integer dec = decimal sng = single bln = boolean dbl = double str = string

Constants Use a Constant where a value is needed but does not change while program is running e.g. VAT, Annual Leave, Pi, Gravity Constants are always global as they are only set up once This allows for easy program modification if value changes We don’t use a Dim statement, but use Const dblPi as double = 3.147 Const sngGravity as single = 9.8

VISUAL BASIC CONTROLS

Intrinsic control The visual toolbox contains the tool we use to draw controls on your frames. Intrinsic controls are one of them. It contain command button and frame controls. It include in the .Exe file. Basic controls are : Checkbox- displays a true/false or yes/no option. You can check any number of checkboxes on a form at one time. Combo box- a textbox with a list box , allows user to type in a selection or select an item from a drop-down list. Command button- carries out a command or action when user chooses it.

Enables you to connect to an existing databases and display information from it on your forms. Label- displays text a user cannot interact with or modify. Listbox -displays a list of items that user can choose from . Option button – the option button control , as part of an option group with other option buttons, displays multiple choices from which a user can choose only one. Picture box- displays bitmap , icons or window metafiles, JPEG or GIF files. It also displays text or cats as a visual contains for other controls.

Textbox- provides an area to enter or display text. Timer – Executes time events at specified time intervals. OLE container – Enables data into a visual basic application. Image – displays bitmaps , icons or window metafiles ,JPEG or GIF files, acts like a command button when clicked. Scrollbar – allow user to add scroll bars to control that do not automatically provide them. Frame – provides a visual and functional container for controls . The most useful intrinsic controls these are nine intrinsic controls are pretty much used on every VB application .start your learning with these and then branch out . command button, image , checkbox, picture box , text box, list box ,label , combo box , option button.

Standard ActiveX Controls The learning edition of visual basic contains a number of activex controls (referred to as standard activex controls) that allow you to add advanced features to your applications. Activex controls have the file name extension . Ocx and can be used in your project by manually adding them to the toolbox. The following table summarizes the standard activex controls available in the learning edition of visual basic.

Icon Control name Class name Description ADO Data Control ADODC Creates a connection to a database using ADO. Assignable to the DataSource property of other controls such as the DataGrid . Common dialog CommonDialog Provides a standard set of dialog boxes for operations such as opening and saving files, setting print options, and selecting colors and fonts. DataCombo DataCombo Provides most of the features of the standard combo box control, plus increased data access capabilities. DataGrid DataGrid A grid control that allows can be data-bound to a data source such as the ADO Data Control. Reading and editing the recordset is possible. DataList DataList Provides most of the features of the standard list box control, plus increased data access capabilities. Microsoft Hierarchical FlexGrid MSHFlexGrid A read-only grid control that can be bound the Data Environment designer to show hierarchical recordsets . 

Other Controls Other ActiveX controls included with all versions of Visual Basic are documented in the Component Tools Guide, and include the following: ImageCombo , ImageList , ListView , ProgressBar , Slider, Statusbar , TabStrip , Toolbar, and TreeView .

Adding and Removing ActiveX Controls You move ActiveX controls to and from the toolbox using the following procedures.   To add an ActiveX control to the toolbox From the  Project  menu, choose  Components . Select the check box next to the name of the .ocx control, and then choose  OK . Once a control is placed in the toolbox, you can add it to a form just as you would an intrinsic control. 

To remove an ActiveX control Remove all instances of the control from the forms in your project. Delete any references to the control in the project's code. If references to a deleted control are left in your code, an error message will display when you compile the application. From the  Project  menu, choose  Components . Clear the check box next to the name of the .ocx control, and then choose  OK . An error message will display if there are remaining instances of the control in your project .

COMMON DIALOG CONTROL: VB provides user facility of using in-built dialog boxes in application. Hence user is saved from the job of design his own dialog boxes. He has just to use common dialog control on form and call appropriate methods. Common dialog control is a special control. It provides its services to application but it need not to be displayed at form at run time. Common dialog control is a component that allows us to access inbuilt libraries. Common dialog control provides an interface between visual basic and the procedures in the microsoft windows.

To Use The Common Dialog Control : Add the common dialog control to the toolbox by selecting components from the project menu. Locate and select the control in the controls tabbed dialog, then click the OK button. On the toolbox, click the common Dialog control and draw it on a form. When you draw a common dialog control on a form, it automatically resize itself. Like the timer control, this dialog is invisible at run time.

The common dialog control allows you to display these commonly used dialog boxes: Open Save As Color Font Print Help

File open and file save common dialog control : File common dialog doesn’t display all files in any given folder normally. File display are limited to those recognized by application. Filter property determines the file to be displayed in File Open or File Save dialog box. DefaultExt property is used to specify the type of file to be displayed. Color Common Dialog Control: It has single property color which returns color selected by user or sets initially selected color when dialog box opened. Font common dialog box: It lets user select and view font, font size and style. Following attributes are set- Color, Font Bold, Font Italic, FontStrikethru, Font Underline, Font Name, Font Size. Print Common Dialog Box: It enables user to select printer, set certain properties of printout like number of copies, number of pages.

Help common Dialog Control: Before using help common dialog box , user must have help files. These files either can be prepared by user or in-built. To display common dialog box through code, its action property must be set. Method Action ShowOpen Displays open dialog box ShowSave Displays Save as dialog box ShowColor Displays Color dialog box ShowFont Displays Font dialog box ShowPrinter Displays Printer Dialog box ShowHelp Invokes Windows help engine

THANK YOU !
Tags