introduction to visual basic P G D C A - 2 ND S e m VIDYA CLASSES SESSION:-2023-24
I N D E X INTRODUCTION TO VISUAL BASIC FEAUTURE OF VISUAL BASIC RAPID APPLICATION DEVELOPMENT Editions of Visual Basic Versions of Visual Basic Advantages Of Visual Basic Disadvantages Of Visual Basic Starting Visual Basic Hardware Requirement Visual Basic Concepts Visual Basic Integrated Development Environment(VBIDE):- Code Editor Window WORKING WITH WINDOWS
Defining Visual Basic Visual Basic is a tool that allows you to develop Graphical User Interface applicà tion . Visual Basic can create windows programs whèreas BASIC can only create DOS based programs. Visual Basic provides massive support for easily creating the user interface to your application in which you use a mouse to type your code that is to be executed. Visual Basic is an event driven programming model. In old BASIC you have to write code to watch for the occurence of user events(pressing the key, using a mouse etc ). Visual Basic provides built in support to internet access.
Visual Basic is one very powerful programming system that helps one to develop sophisticated, graphical applications that can be run on Microsoft Windows Environment. Visual Basic is actually BASIC language, which is visual in its nature. Visual programming style involves a lot of illustrations rather than writing numerous lines of codes to describe the appearance, functioning etc. of the application's interface. The BASIC language (acronym for Beginner's All Purpose Symbolic Instruction Code) was developed by John Kemery in 1960's. BASIC language was hugely popular,for it was simple yet powerful language. The same old BASIC language has now evolved into Visual Basic. Visual Basic was developed in early 1999's by Microsoft Corporation. Visual Basic is also being referred as VB. Introduction TO VISUAL BASIC
Visual Basic programming environment provides all features that are required to develop a graphical user interface as already to use components. In developing such an interface, the programmer employs user-friendly components such as windows, menus, buttons, list boxes etc.. Visual Basic6.0 provides many more powerful features. Some prominent ones are- It is a successor of BASIC language. Visual Basic supports event driven programming. It is an event driven programming language. It is having RAD tools. Visual Basic offers many tools that provide a quick and easy way to develop applications. Visual Basic also provides many wizards that can automate tasks or even automate coding. ( A Wizard is generally an automated way of doing things. The wizard guides you at every step, what to do, how to do etc.) It has useful debugger and error handling facilities. It has array of mathematical string handling and graphical facilities.
Thus, Visual Basic is a high level programming language which provides following features to users: Object Oriented Event Driven Autocompletion Wizard Error Trapping Tools Flexible Environment Crystal and Data Report Help Files Clipboards and Printers Database Connectivity Wizard Facility
RAPID APPLICATION DEVELOPMENT Rapid Development of application is possible through RAD(Rapid Application Development) tools. The RAD tools are the tools that enable one to create applications in shorter time as compared to conventional languages. A range of applications can be created with RAD tools. RAD describes a method of developing software through the use of pre-determined tools or wizards. While developing large applications, the RAD tools are used to create prototypes of the large application. A prototype is the first model that is made of something. The prototype is used as a basis for later improved model.
Editions of Visual Basic Visual Basic is available in three versions, each geared to meet a specific set of development requirements. (i) The Visual Basic learning Edition allows programmers to easily create powerful applications for MS Windows and Windows NT. It includes all intrinsic controls, flex grid, tab and data bound controls. It is also known as Standard Edition and is generally used for learning purposes. (ii) The Professional Edition provides computer professionals with a set of tools for developing solution for others. It includes all the features of the Learning Edition, plus additional Active-X controls, the Internet Information Server Application Designer, integrated Visual Database tools and Data Environment, Active Data Objects, and the Dynamic HTML page designer. Most professional programmers use Professional Edition. (iii) The Enterprise Edition allows professionals to create robust distributed applications in a team setting. It includes all the features of the Professional Edition, plus Back Office tools such as SQL server, Microsoft Transaction Server, Internet Information Server, Visual Source Safe, SNA server and more. Enterprise Edition users are generally those who are working in a networked, distributed environment.
Versions of Visual Basic The Original Visual Basic for DOS and Visual Basic for windows were introduced in 1991. The next version Visual Basic3.0 was released in 1993. It was vast improvement over previous version. The next version Visual Basic4.0 was released in the year 1995(added 32bit publication support). Visual Basic 5.0 was released in the late 1996. New Environment supported creation of Active X controls, deleted 16 bit application support. Visual Basic6.0 was released with the following features:- Faster compiler. New Active X Data control Object. Allows Database Integration with wide variety of applications. New Data Report Designer. New package and Deployment Wizard. Additional Internet capabilities.
Advantages Of Visual Basic It has a simple language. It has comprehensive on-line help facilities. It supports GUI features. It supports the facilities of integration of COM components written in other languages. It has Object Linking and Embedding(OLE) facilities.
Disadvantages Of Visual Basic Programs written in Visual Basic is slower and less robust. Visual Basic programs has limited portability in Windows Environment. It has very limited access to library. OLE(Object Linking and Embedding) needs large amount of memory.
Starting Visual Basic To startup Visual Basic:- 1) Click at the Start Button. 2) Select All programs -----> Microsoft Visual Basic. or If Visual Basic is installed as a part of Microsoft Visual Studio Suite then, All Progams -------> Microsoft Visual Studio ------> Microsoft Visual Basic6.0 And Visual Basic's startup dialog box appears on the screen.
Hardware Requirement The followings are the hardware requirements for Visual Basic:- 1) Pentium 90MHz or higher microprocessor. 2) Video Graphic Adaptor(VGA) monitor (640*480 resolution or higher). 3) 24MB RAM, Windows 95/98 or higher version. 32MB RAM, or higher for Windows NT. 4) Color monitor. 5) Compatible mouse.
Visual Basic Concepts Visual Basic is a Windows Development Language, which also supports Event Driven Programming. Also, coding is done interactively in Visual Basic. Working of Windows, Events, and Messages A window can be thought of as a rectangular region with its own boundaries. There are actually many other types of windows. A command button is also a window. Icons, text boxes, option buttons and menu bars are all windows. The Windows Operating System manages many of these windows by assigning each one a unique id number(called Window Handle). Events can occur through user actions such as a mouse click, a key press etc. through programmatic control, or even as a result of another window's actions. An Event refers to the occurence of an activity.Each time an event occurs, it causes a message to be sent to the operating system. The system processes the message and broadcasts it to the other windows. Each window can then take the appropriate action based on its own instructions for dealing with that particular message.
A message is the information/request sent to the application. Dealing with all of the possible combinations of windows, events and messages could be mind-boggling. Fortunately, Visual Basic insulates you to deal with all of the low-level message handling. Many of the messages are handled automatically by Visual Basic. This allows to quickly create powerful applications without having to deal with unnecessary details. The Event Driven Model: In an Event Driven application, the code doesn't follow a predetermined path rather it executes different code sections in response to events. Events can be triggered by the user's actions, by messages from the system or other applications, or even from the application itself. The sequence of these events determines the sequence in which the code executes, thus the path through the application's code or the sequence of execution differs each time the program runs. Interactive Development: The traditional application development process can be broken into three distinct process or steps: Writing, Compiling and Testing code.
Unlike the traditional languages, Visual Basic uses an interactive approach to development that merges these three steps: With most languages, if any mistake is there in writing the code, the error is caught by the compiler when the application is compiled. The error is then found and fixed. The compile cycle is again begun, repeating the process for each error found. Visual Basic interprets the code when entered, catches and highlights most syntax or spelling errors there and then. It's almost like having an expert watching over your shoulder as code is entered. In addition to catch the errors on the fly, Visual Basic also partially compiles the code as it is entered. If the compiler finds an error, it is highlighted in the code. You can fix the error and continue compiling without having to start over. Because of the interactive nature of Visual Basic, the application can be run frequently as one develops it. This way the test of the effects of code can be done while working rather than waiting to compile later.
Visual Basic Integrated Development Environment(VBIDE):- When you start a new project, Visual Basic shows the screen. This is Visual Basic Integrated Development Environment( VBIDE). The Visual Basic IDE consists of the following elements:- Title Bar Menu Bar Tool Bars Tool Box Form Designer Project Explorer Window Properties Window Form Layout Window TITLE BAR The Title Bar displays the title of the project. Bydefault , Visual Basic will give names as Project1, Project2 ----- etc , to the project. The title bar also displays the word (design). This means the application is currently in design mode. A Visual Basic application works in three modes: Design Mode Run Mode Break Mode
While application is being created or designed, it is in Design Mode. When the application is executing, it is said to be in Run Mode. And while an application is in a state of suspension, it is said to be in Break Mode. MENU BAR AND PULL DOWN MENU A Menu Bar is displayed directly below the title bar and includes a lot of options. Each option on the Menu Bar has a drop down list of items (known as Pull-down Menus) that help to perform various tasks. TOOL BARS A Tool Bar is a bar that displays icons for commonly used tasks. The Standard Toolbar of Visual Basic displays icons for the most frequently used commands in Visual Basic. The Standard Toolbar can also contain buttons from toolbar or properties window. TOOL BOX Forms are the main part of the project .Forms are used to display various various controls that form the user interface. Forms are used to display things like labels, graphics, controls etc Controls are objects such as text boxes, buttons, labels, list boxes etc , that are
drawn on form to get data input or to display output. A Toolbox is a window that displays a set of tools that may be used to place controls on a form. The buttons on the toolbox depict controls. FORM DESIGNER The Form Designer window is the Form window in design form. In Form Designer Window, different controls are placed on the form. A grid of dots are seen on the form designer window. The purpose of grid is to help in lining up controls at the time of design. These dots disappear at the time of form execution. PROJECT EXPLORER WINDOW This window shows the list of forms and modules in a project. A project is a collection of files used to build an application. All these files are listed in Project Window. PROPERTIES WINDOW A form may consist of many objects ie , controls on it. Every control has some properties associated with it. A property is a characteristic of an object such as its size, its caption or its colour etc. The Properties Window lists the properties of a selected control or for the form. If the Properties Window is not displayed then it can be viewed through View ----> Properties Window command or by pressing F4 key. FORM LAYOUT WINDOW The Form Layout Window shows how big a form is in relation to the screeen . It also displays the position of the force where it'll be displayed when the project is run.
Code Editor Window The Code Editor Window is where the Visual Basic code for an application is written. By code we mean language statements, constants and declarations. A separate Code Editor Window is created for each form or control that you create in your application. Using the Code Editor Window, any of the codes of the application can be quickly viewed and edited. To Open The Code Window Double click the form or control for which you choose to write code. Or from the Project Explorer Window, select the name of a form or module, and choose the View Code Button from the Project Explorer's toolbar or press F7 key.
WORKING WITH WINDOWS Opening Windows There are different types of windows in Visual Basic interface such as Project Explorer Window, Properties Window, Form Layout Window, Toolbox etc. Sometimes, when you start Visual Basic you don't see any one or all of these windows in the initial screen. To open the desired window, just click upon the View option on the Menu Bar and select the name of the desired window to be opened. Windows can be closed by clicking at their close(X) button.
Resizing And Moving Windows To resize a window, take the mouse pointer to any of the boundaries of the window. Your cursor will change into double ended arrow. Now drag the window in desired direction to enlarge or reduce its size. To resize Form Designer, you have to place the mouse pointer on the size handles(rectangular dots on the boundary) and then drag it to new location.
DOCKING WINDOWS Docking means connecting. Many of the windows in IDE can be docked or connected to each other or to the edge of the screen. These include Toolbox, Form Layout Window, Project Explorer, Properties Window etc. A window that can be resized or moved and connected to other windows is known as Dockable Window. Most of the Visual Basic's windows are dockable . To Dock Or Undock A Window To dock or undock a window the following procedures should be followed:- If you look at the initial screen of Visual Basic, you generally find some docked windows. To undock a docked window, just drag its title bar to a new location. The moment you release mouse button, the window will be undocked. To dock undocked windows, you need to follow the reverse process ie , drag the title bar of the undocked window to the boundary of other window with which it is to be docked and release the mouse button. The two windows will get docked. Windows can be docked with the main Visual Basic Window also, by following the same procedure above.
Quitting Window(Visual Basic) To quit Visual Basic, you need to select File ----> Exit command or press Alt+Q . You can also quit from Visual Basic the way you exit from most of the window applications ie , by pressing Alt+F4 or by clicking the close(X) button or by double clicking its control menu icon that appears on the upper left corner of the window. Thus it can be concluded that to quit from Visual Basic you can press:- 1) File ----> Exit command. 2) Alt+Q 3) Alt+F4 or 4) Close(X) Button