Visual Basic (MSC -IT (III Sem)
Total Page:16
File Type:pdf, Size:1020Kb
Biyani's Think Tank Concept based notes Visual Basic (MSC -IT (III Sem) Dhanesh Gupta Anju Bhatt Lecturer Deptt. of Information Technology Biyani Girls College, Jaipur 2 Published by : Think Tanks Biyani Group of Colleges Concept & Copyright : Biyani Shikshan Samiti Sector-3, Vidhyadhar Nagar, Jaipur-302 023 (Rajasthan) Ph : 0141-2338371, 2338591-95 Fax : 0141-2338007 E-mail : [email protected] Website :www.gurukpo.com; www.biyanicolleges.org First Edition : 2012 While every effort is taken to avoid errors or omissions in this Publication, any mistake or omission that may have crept in is not intentional. It may be taken note of that neither the publisher nor the author will be responsible for any damage or loss of any kind arising to anyone in any manner on account of such errors and omissions. Leaser Type Setted by : Biyani College Printing Department (Visual Basic) 3 Preface am glad to present this book, especially designed to serve the needs of I the students. The book has been written keeping in mind the general weakness in understanding the fundamental concepts of the topics. The book is self- explanatory and adopts the “Teach Yourself” style. It is based on question- answer pattern. The language of book is quite easy and understandable based on scientific approach. Any further improvement in the contents of the book by making corrections, omission and inclusion is keen to be achieved based on suggestions from the readers for which the author shall be obliged. I acknowledge special thanks to Mr. Rajeev Biyani, Chairman & Dr. Sanjay Biyani, Director (Acad.) Biyani Group of Colleges, who are the backbones and main concept provider and also have been constant source of motivation throughout this Endeavour. They played an active role in coordinating the various stages of this Endeavour and spearheaded the publishing work. I look forward to receiving valuable suggestions from professors of various educational institutions, other faculty members and students for improvement of the quality of the book. The reader may feel free to send in their comments and suggestions to the under mentioned address. Author 4 Chapter-1 Integrated Development Environment Q.1 What is an IDE? Ans.: Visual Basic is not only a language. It’s an Integrated Development Environment in which you can develop, run, test and debug your applications. The types of project that you can create in Visual Basic are as follows : (i) Standard EXE : These are the typical applications that you develop with previous versions of Visual Basic. (ii) ActiveX EXE, ActiveX DLL : These types of projects are available with the Professional edition. ActiveX components are OLE automation servers. (iii) ActiveX Control : This type of project is also a feature of the Professional edition. We use it to develop your own ActiveX controls. (iv) ActiveX Document EXE, ActiveX Document DLL : ActiveX documents are in essence Visual Basic applications that can run in the environment of the container that supports hyper-linking. (v) VB Application Wizard, VB Wizard Manager : The Application Wizard takes you through the steps of setting up the skeleton of a new application. The Wizard Manager lets you build your own wizard. (vi) Data Project : It’s identical to the Standard EXE project type, but it automatically adds the controls that are used in accessing databases to the Toolbox. (Visual Basic) 5 (vii) DHTML Application : VB6 allows you to build Dynamic HTML pages that can be displayed in the browser’s window on a client computer. (viii) IIS Application : VB6 allows you to build applications that run on the Web server and interact with clients over the Internet with the Internet Information Server. (ix) Addin : You can create your own add-ins for the VB IDE. These are special commands you can add to Visual Basic’s menus. (x) VB Enterprise Edition Controls : It simply creates a new Standard EXE project and loads all the tools of the Enterprise Edition of Visual Basic. Q2 What is visual basic? Explain characteristics and features. Ans Visual Basic (VB) is a third-generation event-driven programming language and integrated development environment (IDE) from Microsoft for its COM programming model first released in 1991. Visual Basic is designed to be relatively easy to learn and use. Visual Basic was derived from BASIC and enables the rapid application development (RAD) of graphical user interface (GUI) applications, access to databases using Data Access Objects, Remote Data Objects, or ActiveX Data Objects, and creation of ActiveX controls and objects. Scripting languages such as VBA and VBScript are syntactically similar to Visual Basic, but perform differently. A programmer can put together an application using the components provided with Visual Basic itself. Programs written in Visual Basic can also use the Windows API, but doing so requires external function declarations. Though the program has received criticism for its perceived faults, from version 3 Visual Basic was a runaway commercial success,[4] and many companies offered third party controls greatly extending its functionality. The final release was version 6 in 1998. Microsoft's extended support ended in March 2008 and the designated successor was Visual Basic .NET (now known simply as Visual Basic). 6 Language features Like the BASIC programming language, Visual Basic was designed to be easily learned and used by beginner programmers. The language not only allows programmers to create simple GUI applications, but can also develop complex applications. Programming in VB is a combination of visually arranging components or controls on a form, specifying attributes and actions of those components, and writing additional lines of code for more functionality. Since default attributes and actions are defined for the components, a simple program can be created without the programmer having to write many lines of code. Performance problems were experienced by earlier versions, but with faster computers and native code compilation this has become less of an issue. Although programs can be compiled into native code executables from version 5 onwards, they still require the presence of runtime libraries of approximately 1 MB in size. This runtime is included by default in Windows 2000 and later, but for earlier versions of Windows like 95/98/NT it must be distributed together with the executable. Forms are created using drag-and-drop techniques. A tool is used to place controls (e.g., text boxes, buttons, etc.) on the form (window). Controls have attributes and event handlers associated with them. Default values are provided when the control is created, but may be changed by the programmer. Many attribute values can be modified during run time based on user actions or changes in the environment, providing a dynamic application. For example, code can be inserted into the form resize event handler to reposition a control so that it remains centered on the form, expands to fill up the form, etc. By inserting code into the event handler for a keypress in a text box, the program can automatically translate the case of the text being entered, or even prevent certain characters from being inserted. Visual Basic can create executables (EXE files), ActiveX controls, or DLL files, but is primarily used to develop Windows applications and to interface database systems. Dialog boxes with less functionality can be used to provide pop-up capabilities. Controls provide the basic functionality of the application, while programmers can insert additional (Visual Basic) 7 logic within the appropriate event handlers. For example, a drop-down combination box will automatically display its list and allow the user to select any element. An event handler is called when an item is selected, which can then execute additional code created by the programmer to perform some action based on which element was selected, such as populating a related list. Alternatively, a Visual Basic component can have no user interface, and instead provide ActiveX objects to other programs via Component Object Model (COM). This allows for server-side processing or an add-in module. The runtime recovers unused memory using reference counting which depends on variables passing out of scope or being set to "Nothing", resulting in the very common problem of memory leaks. There is a large library of utility objects, and the language provides basic object oriented support. Unlike many other programming languages, Visual Basic is generally not case sensitive, although it will transform keywords into a standard case configuration and force the case of variable names to conform to the case of the entry within the symbol table. String comparisons are case sensitive by default. The Visual Basic compiler is shared with other Visual Studio languages (C, C++), but restrictions in the IDE do not allow the creation of some targets (Windows model DLLs) and threading models. Characteristics Visual Basic has the following traits which differ from C-derived languages: Statements tend to be terminated with keywords such as "End If", instead of using "{}"s to group statements. Multiple variable assignment is not possible. A = B = C does not imply that the values of A, B and C are equal. The boolean result of "Is B = C?" is stored in A. The result stored in A would therefore be either false or true. 8 Boolean constant True has numeric value −1.[5] This is because the Boolean data type is stored as a 16-bit signed integer. In this construct −1 evaluates to 16 binary 1s (the Boolean value True), and 0 as 16 0s (the Boolean value False). This is apparent when performing a Not operation on a 16 bit signed integer value 0 which will return the integer value −1, in other words True = Not False. This inherent functionality becomes especially useful when performing logical operations on the individual bits of an integer such as And, Or, Xor and Not.[6] This definition of True is also consistent with BASIC since the early 1970s Microsoft BASIC implementation and is also related to the characteristics of CPU instructions at the time.