Beruflich Dokumente
Kultur Dokumente
1) What is Visual Basic ? What are the various Editions of Visual Basic Available in market ?
Visual basic is a powerful application development tool developed by Microsoft. It is used for creating customized windows based programs. Visual Basic is the fastest and easiest way to create application for Microsoft Windows. Visual Basic provides a complete set of tools to simplify rapid application development, whether we are an experienced programmer or new to windows programming. Visual Basic consists of two parts Visual and Basic. The Visual part refers to the method used to create the graphical user interface (GUI). Rather than writing numerous lines to code to describe the appearance and location of interface elements, We simply add objects which are prebuilt into place on screen. This part makes visual basic a true RAD ( Rapid Application Development) tool. The BASIC part refers to the BASIC language since Visual Basic is a descendent of BASIC (Beginners All Purpose Symbolic Instruction Code) which was often the first language that programmers used to learn in order to become familiar from the original BASIC language and now contains several hundred statements , functions and keywords , may of which relate directly to the Windows GUI. Visual Basic is not just a language but is an Integrated Development Environment (IDE). An IDE is basically a term commonly used in the programming world to describe the interface and environment where we can develop , run , test and debug our applications. The Visual Basic is available in the following three editions : 1. Learning Edition : It allows programmers to easily create powerful applications for the Windows and Windows NT operating systems . Basically it contains all the tools like Visual Basic development environment , standard controls, samples , Setup Wizard and other tools that are required for creating a powerful application. 2. Professional Edition : It adds to the capabilities of the Learning Edition by allowing us to create client/Server or Internet Enabled applications. The Professional Edition of Visual Basic has all the features that are found in the Learning Edition and includes advanced features such as tools to develop ActiveX and Internet controls. 3. Enterprise Edition : In incorporate environment benefit by using the advanced features in the Enterprise Edition to create robust distributed applications in a team setting. It includes all the features found in the professional Edition. It also includes Microsoft Visual Source Safe for source code control and the Automation and Component Manager.
Neeraj Chopra
Neeraj Chopra
Neeraj Chopra
Neeraj Chopra
Neeraj Chopra
Form Modules: Form modules (.FRM filename extensions) are the foundations of
any visual basic application. They contain the textual description of a Form and its control including their property settings. They can contain Form level declarations of types, constants, variables and external procedures that handle events and general procedures. Form are a part of our application that are visible to users at run time. Class Modules: Class modules (.CLS filename extension) mark up the foundation for the object-oriented programming in Visual Basic. We can write code in Class modules to create new objects. These new classes can include their own customized properties, methods and events. All of the properties and methods we create can also be used by other object in our application.
7) What are the various step one has to follow for managing project
Neeraj Chopra
Neeraj Chopra
9) What is Form and explain the various properties of the form and also list the various events which are associated with a form
A Visual Basic form is used to develop the user interface . It is basically a window where we can different elements in order to create a complete application. Every application we see on the screen is based on some type of form. Forms have their own properties , events and methods which are used to control their appearance and behavior. A default form Form1 is add to development environment when Visual Basic starts. It applies a default set of properties to this form and any forms that are added to the project. The properties of these forms can be changed for its appearance and behavior at design time or at run time. Properties of form 1. Border Style property: It determines how the border of a form behaves and looks. This property is used for setting form size that can be set at design time and cannot be changed at run time. Setting Description 0-None None (No border) 1-Fixed Single This setting that the forms cannot be resized by dragging 2-Sizeable It is default setting for Visual Basic forms and most other window applications. The form can be resized by dragging borders 3-Fixed Dialog It can include control menu box and title bar 4-Fixed It displays a nonsizeable window with a close button Toolwindow 5-Sizeable It displays a sizeable window with a close button, but does not ToolWindow include a maximize or minimize button . 2. Caption Property : It is a text that appears on the title bar of the form. The caption can be set either at design time by using Caption property in the properties window or by writing code at run time 3. ControlBox : The control menu is a simple menu that allows the user to restore , move , resize , minimize , maximize and close a form. This button can be enabled in the form by setting the forms controlbox property in the forms property window. It can set to true or false. When we set to true then also set the Border style property to either 1,2 or 3 to display the control box. 4. Font : It is used to set the font for use in the form. Whatever controls are placed on the form will be by default use the font set for the form. Double click-click font property. 5. Name : In Visual Basic the name property is the most important property as it is the name of the control that is refers to when the program runs. The default name
Neeraj Chopra
10) What are controls and Explain its various types in details
Controls are objects that are placed within form objects. Command buttons, List boxes and Scrollbars are examples of controls. Each type of control has its own set of properties, methods and events suitable for a particular purpose. The controls can be added to a form by just double clicking on the control or by drawing the selected control on a form by dragging the mouse around the area where we want the control to be placed. When a control is created, Visual Basic gives a default name indicating the type of control, plus a unique integer which can be changed by starting it with a letter followed by number. Classification of controls There are two types of controls in Visual Basic 1. Standard controls: The Standard Controls also known as Intrinsic Controls are always available on the toolbox 2. ActiveX controls: These are those controls which can be added later on to the toolbox. This can be either third party controls like some of them are provided by Microsoft or can be user created controls. Standard controls Label A Label control is a graphical control we can use to display text that user cant change directly. It used to display static information. It displays read only text; the user cannot edit the text directly. The property which is set in a label control is the caption property
Neeraj Chopra
Neeraj Chopra
10
Command Button It used to begin , interrupt or end a process. When chosen a command button appears pushed in and so is sometimes called push button. One can attached an access key to a command button by placing an ampersand (&) before a character in the caption property. Commonly used Command button properties Caption : It returns or sets the text is displayed in the command button Name : It returns the name used in code to identify the command button Value : It returns or sets a value indicating whether the button is chosen. This is not available at design time
CheckBox It used to give the user a True/False or Yes/No option . One can use checkbox control in groups to display multiple choices from which the user can select one or more. Commonly used checkbox properties are Alignment : It specifies the alignment of the checkbox with respect to the caption Caption : It specifies the text appears besides the checkbox Enabled : It sets a value that specifies whether the checkbox can respond to user generated events Name : It assigns a name to identify the checkbox Value : It is used to specify the state of checkbox. The value 0 or false indicates that the checkbox is deselected . Value 1 or true indicates that the checkbox is selected.
Option Button An option button control displays an option that can be turned on or off Commonly used checkbox properties are :
Neeraj Chopra
11
ScrollBar
A ScrollBar enables the user to select a value by positioning it at the desired location. It represents the set of values. The Min and Max property represents the minimum or maximum value. The value property of the ScrollBar represents its current value, which is any integer between the minimum and maximum value. The Horizontal and Vertical scrollbar are identical as they share the same properties , events and methods.
Timer
The timer control is one of the few controls always hidden at run time. It can execute code at regular interval . It has some important properties Interval : The interval property is measured in milliseconds and is represented by a value from 1 to 65,535 Enabled : The enabled property determines if the timer control will invoked the timer event in the time specified by the interval property.
Neeraj Chopra
12
Neeraj Chopra
13
11) What are Data types ? Explain the various data types available in Visual Basic ?
Data types are explanation of data stored in the variables. Visual Basic also supports most of the fundamental data types used in several programming languages. Data Type Byte Boolean Integer Long Single(floating point) Double(floating point) Currency Decimal Date Object String (variable length) String (Fixed length) Variant User Defined Storage size 1 bytes 2 bytes 2 bytes 4 bytes 4 bytes 8 bytes 8 bytes 14bytes 8 bytes 4 bytes 10 bytes + string length Length of string 16 bytes Number required by elements
Byte Data type Byte variables are stored as single , unsigned 8-bit numbers ranging in value 0-255. The byte data type is useful for containing binary data Boolean Data type Boolean variables are stored as 16-bit numbers but they can only be true or false. Example : Dim x as Boolean
Neeraj Chopra
14
Neeraj Chopra
15
A variable has a variable name by which it is referred to and can store a value into it. For example there is variable name Radius to store a value in it as Dim Radius as float Radius=4.5 A variable has to be created first only then one can use it Empty variables If a variable has been declared but not value is assigned to it , it is said to empty variables Static Statements Variables declared with the static statement retain their values as long as the code is running Public Statement Used at module level to declare public variables and allocate storage space. Variable declared using the Public statement are available to all procedures in all modules in all application Private Statement Used at module level to declare private variables and allocate storage space. Private variables are available only to the module in which they are declared. Scope of Variable The scope of variables refers to the accessibility or visibility with in the project. The level at which the variable is declared determines the accessibility of a variable. It is important for variables used with in procedures : Procedure level variables are recognized only in the procedure in which they are declared Local variables declared with static statement exist as long as the code is running while the variable declared with Dim statement exist only as long as the procedure in the module but is not available to code in other modules. A module level variable is available to all procedures in the module but is not available to code in other module If public variables in different modules share the same name, it is possible to differentiate between them in code. For example if integer variable Myint is 16
Neeraj Chopra
Neeraj Chopra
17
What is an operator ? Explain the various types of operators available in Visual Basic with the help of an example ?
Operators are special symbols or words used to describe an operation or an action which is to take place between two or more or among more than two values. Operators are available in Visual Basic for performing arithmetic,comparison and logical operations. The different categories of operators in Visual Basic are Arithmetic operator Comparison operator Logical operator Concatenation operator
Arithmetic operators These operators are used to perform mathematical operations on two numbers or numeric expression. The list of the arithmetic operators are +,-,*,/,Mod Comparison Operator The comparison operators are used to compare expression. They compare expressions and return a Boolean value. Operator Description > Greater than < Less than >= Greater than equals to <= Less than equals to = Equals to <> Not equals to Like Operator It is used to compare two strings and returns a Boolean value. If strings matches pattern results is True, if there is no match result is False. If either string is Null, result is Null. Syntax Result = string like pattern Pattern may include following wildcards ? : for matching any single character in string
Neeraj Chopra
18
Neeraj Chopra
19
15) What is Loop Statements ? Explain the various types of Loop statements
Loop structures of Visual Basic are used for iteratively performing a statement / statement block. They are used when a group of statements have to be executed repeatedly based on a condition. FOR.LOOP This is used when the repetition is to be done for a certain number of times and a counter may be used. Private Sub Command1_Click() Dim i As Integer For i = 1 To 10 MsgBox "i=" & i Next i End Sub Another Example of FOR LOOP Private Sub Command1_Click() Dim i As Integer For i = 1 To 10 step 2 MsgBox "i=" & i Next i End Sub DO While Loop This loop test the condition first and if true executes the statement which are given in the loop Private Sub Command1_Click() Dim i As Integer i=1 Do While i <= 10 MsgBox "i= " & i i=i+1 Loop End Sub While Loop This loop test the condition first and if true executes the statement which are given in the loop Private Sub Command1_Click() Dim i As Integer i=1
Neeraj Chopra
20
Neeraj Chopra
21
18) What is an Event ? Explain the Event Driven programming model ? Explain the various types of events?
Events : Events are the actions recognized by a form or control. Events occur a user, operating system or application interacts with the objects of a program. Any action performed by pressing a key one the keyboard or clicking a mouse for which code can be written is an event procedure that runs whenever the event occurs as a result of the user actions or program code, or they can be triggered by the system. Depending on the event the corresponding procedure is executed but some events recognized by one object might not be the same as recognized by other objects. Event Driven Programming : When a program is event driven its code is executed in response to events invoked by the user, operating system or application. This differs from procedural programming where the program starts at the first line of code and follows a defined pathway calling procedures as needed. In traditional or procedural applications the application itself determines which portion of code is to be executed and in what sequence. Execution starts with the first line of code and follows the coding sequence defined in the application. At times controls are transferred to other parts of the program through statements and procedures. Whereas application written in Visual Basic are event driven. In an event driven application the code does not follow a predetermined path it executes different code sections in response to events. Events can be triggered itself by the user actions, by messages from the system or other application or even from the
Neeraj Chopra
22
Neeraj Chopra
23
Controls on a form such as command button and frames are object Form Each form in a Visual Basic project is a separate object DataBase Database objects are objects and contain other objects like fields and indexes Chart A Chart in Microsoft Excel is an object. Each object in Visual Basic is defined by a class. For example The controls on the Toolbox in Visual Basic represents classes. The objects known as control doesnt exist until we draw it on a form. When we create a control we are creating a copy or instance of the control class. That instance of the class is the object we refer to in our application. The form we work with at design time is a class. At run time Visual Basic creates an instance of the forms class. An object provides code we dont have to write. For example we could create our own File Open and File Save dialog boxes. Instead we can use the common dialog control provided by Visual Basic. We could write our own scheduling and resource management code. We can use the Calender , Resources and Task objects provided by Microsoft Project. Visual Basic provides the tools to allow us to combine objects from different sources. We can now build custom solutions combining the most powerful features of Visual Basic and applications that support Automation. Automations is a feature of the Component Object Model (COM) an industry standard used by applications to expose objects to development tools and other applications.
Neeraj Chopra
24
Neeraj Chopra
25
22) What are Dynamic Link Libraries (DLL) ? What are the benefits of using DLL?
When we need capabilities that do beyond the core language and controls provided with VB we could make direct calls to procedures contained in DLLs. By calling procedures in DLLs we can access the thousands of procedures that form the backbone of Microsoft Windows operating system as well as routines written in other languages. As their name suggests, DLLs are libraries of procedures that applications can link to and use at run time rather that link to statically at compile time. This means that the libraries can be updated independently of the application and many applications can share a single DLL. Microsoft windows itself is comprised of DLLs, and other applications call the procedures within these libraries to display windows and graphics, manage memory or perform other tasks. These procedures are sometimes also referred to as the Windows APIs or application programming interfaces. Benefits of DLLs 1. Accomplish tasks not available in VB DLLs can perform tasks that are not possible in VB directly. For example we can invoke a DLL procedure that causes our application to remain the topmost window. 2. Improve performance -- DLLs execute much faster than VB code. If we have a procedure that requires maximum performance, we can write a DLL procedure and then invoke the DLL from VB 3. Get Update independently of the application DLLs can be updated without recompiling the application that invoked the DLL. This provides greater modularity and application maintenance.
Neeraj Chopra
26
Neeraj Chopra
27
Neeraj Chopra
28
Neeraj Chopra
29
Neeraj Chopra
30
33) What are the Various categories of accessing database is available in Visual Basic ?
Visual Basic can access three categories of databases: 1. Jet Databases: Databases are created and manipulated directly by the Jet engine. The Jet engine is the data manager component of Microsoft Access and Visual Basic 2. ODBC (Open Database Connectivity ): Visual Basic also allows access to a database on a Network. These include client server databases that conform to the ODBC standard such as oracle. Most databases that support ODBC can be accessed.
Neeraj Chopra
31
Neeraj Chopra
32
Neeraj Chopra
33
Neeraj Chopra
34
Neeraj Chopra
35
Neeraj Chopra
36
Neeraj Chopra
37
Neeraj Chopra
38
Neeraj Chopra
39