ASSIGNMENT

VISUAL BASIC

Q.1. DEFINITION OF VB ?
ANS:- Visual basic is a visual version of a computer language named BASIC. BASIC is high level programming language that supports text-only environment. BASIC is Beginners¶ AllPurpose Symbolic Instruction Code. It is an instruction code that uses symbols and is meant for all purposes-scientific or business. Each instruction is executed i.e. run sequentially. Since BASIC is a Beginner¶s language, it is easy to learn and write. VISUAL BASIC moves a step forward, uses the syntaxes of BASIC and runs the events in the graphical environment. There are no. of objects in the graphical environment. Each of them can programmed independently to respond to the events (actions). This language is also called Rapid Application Development(RAD) tool because the programmer can develop a wide range of windows, web, mobile and office applications on a rapid pace. The language is accessible to everyone from novice programmer to advanced system architect.

Q.2. FEATURES OF VB ?
ANS:- Visual basic was designed to be easy, to learn and use. The language not only allows programmers to easily create simple GUI applications, but also has the flexibility to develop fairly complex applications as well. The features of visual basic can be listed below:1. Programming in visual basic is a combination of visually arranging components or control 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. 2. Forms are created using drag and drop techniques. A toolbox is used to place controls (examples are, text boxes, buttons, etc.) on the form (window). 3. 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. 4. 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.

If you don¶t supply a data type. The language has basic object oriented support. 10. which can then execute additional code created by the programmer to perform some action based on which element was selected. An execute handler is called when an item is selected. String and Currency type. but can be made case sensitive if so desired. ActivX controls. 11.3. The variant data type is like a chameleon. When you declare a variable. Controls provide the basic functionality of the application. dim or static statement with the help of As type clause. 7. Visual basic component provide ActiveX objects to other programs via Component Object Model (com).g. Unlike many other programming languages. DECLARING VARIABLES WITH DATA TYPES The data type of the variable is declared using private. Double. For example. the programmer seldom needs to specify additional libraries. you can supply a data type for it.. The data type of a variable determines what type of data will be stored in the computer¶s memory.Data types control the internal storage of data in visual basic. 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 entry. DATA TYPES OF VB ? ANS:. no maximize/minimize control) can be used to provide pop-up capabilities.5. 8. a dropdown combination box will automatically display its list and allow the user to select any element. Since the more common components are included in the default project template. 9. but is primarily use to develop Windows Applications and to interface web database systems. while programmers can insert additional logic within the appropriate event handlers. Visual basic can create executables (EXE). This allows for server-side processing or an add-in module. the variable is given the variant data type. DLL files. visual basic is generally not case sensitive.it can represent many different data types in different situations. String comparisons are case sensitive by default. such as populating a related list. Visual basic can handle a variable more efficiently if it is declared with a type for it. Dialog boxes with less functionality (e. public. Q. 6. respectively :Private I As Integer . It helps the computer set aside the right amount of memory for the variable. Example :The following statements declare an Integer.

648 2. type and value the data type can store :S.147. 9999 Scaled Integer Other types of datatype are :- . bytes ³string´) of ³Hello. BillsPaid As Currency Private Test .Dim Amt As Double Static YourName As String Public BillsPaid As Currency A declaration statement can combine multiple declarations :Private I As Integer .In the preceding example. World!´ characters 1-Byte A single E. 1000 to Dec 31.0*10-38 to 6 Double Floating point +-1.0 *10-300« 7 8 Currency String 9 10 Char Date +922.685. Amt As Double Private YourName As String .g.g.203. ³h´ character 8-byte Double Jan 1.337.147.5807 1 byte/character + 2 A sequence (or 0 to 65535 bytes total E.647) 0 to 255 True (-1) or False (0) +-1.477. 7-digit Precision 8-byte.NO. 14-digit Precision 8-byte TYPE Integer Integer Integer Integer Floating point VALUE IT CAN STORE (-32768 to +32768) (-2. Amount . J As Integer NOTE:. the variables test and amount are of the variant data type and not integer as you expected.483.483. The following table provides different data types along with their size. DATA TYPES 1 2 3 4 5 Integer Long Byte Boolean Single SIZE 2-byte 4-byte 1-byte 2-byte 4-byte.

Floating-point(single and double) numbers have much larger ranges than currency. or memory Currency The highest positive value of a single data type is 3. it cannot represent a negative number.4 times 10 to the 38th power.e. EXAMPLE 12 THE STRING DATA TYPE String data type helps in storing a set of characteristics. Recordset ± It is a database type. the highest positive value of a double data type is 1. or about 1.57 Single. Using a numeric data type generally uses less storage space than a variant. the string grows or shrinks as you assign new data to it. Since byte is an unsigned type with the range 0-255.) Variant ± It is of any type. Slow More Double.8 times 10 to the 308th power. THE BYTE DATA TYPE Byte data type stores binary data.  Integer  Long(long integer)  Single(single-precision floating point)  Double(double-precision floating point)  Currency The currency data type supports upto four digits to the right of the decimal separator and fifteen digits to the left.a. but can be subject to small rounding errors. Database. NUMERIC DATA TYPES Numeric data type stores number value in the variable. b.402823E+38.) Workspace. it is an accurate fixed-point data type suitable for monetory calculations. or 3. All operators that work on integers work with the byte data type except unary minus.Next Loop Fraction 3. STORES Whole numbers TYPE OPERATIONS CONSUMES USE Integer or Faster Less memory Counter Long variable in For«. . Let us understand the different data types available in VB. Visual basic supplies several numeric data types. It is variable-length string i.79769313486232D+308.

5. and midday is 0. Boolean data type is used when the variable is used to check a condition. while values to the right of the decimal represent time. . use code like this : Dim EmpName As String *50 THE BOOLEAN DATA TYPE Boolean data type stores the value true or false. When other numeric data types are converted to date. EXAMPLE :Dim blnRunning As Boolean µCheck to see if the tape is running.Private S As String You can then assign strings to this variable and manipulate it using string functions :S = ³Database´ S = Left(S. negative whole numbers represent dates before December 30. The default value of Boolean is False. values to the left of the decimal represent date information. If Recorder. Midnight is 0. 4) You can also declare strings that have a fixed length using the following syntax :String * size EXAMPLE:To declare a strings that is always 50 characters long. yes or no. THE DATA DATA TYPE Data data type stores the values in date or time format. or on or off.direction = 1 then blnRunning = true end if In the above example blnRunning is a Boolean variable which stores a simple yes/no setting. 1899.

toolbars. When working with other applications¶objects. This allows the application to perform faster at run time. This group of tools is collectively called the Integrated Development Environment (IDE). Visual basic can resolve references to the properties and methods of objects with specific types before you run an application. these controls are added to the tool box. in the preceding case. displaying a short description of the control. Q. EXPLAIN IDE ENVIRONMENT ? The visual basic development environment includes an assortment of menus. THE TOOLBOX The toolbox contains the various controls that can be placed on a form. Dim objDb As Object Set objDb = OpenDatabase(³c:\vb5\biblio.mdb´) When declaring the object variables. However. Although this environment can look complex to a new user of visual basic. When you place your mouse cursor over any of the controls on the toolbar.THE OBJECT DATA TYPE Object variables are stored as 32-bit (4-byte) addresses that refer to objects within an application or within some other application. database instead of object) rather than the generic object. declare objects as they are listed in the classes list in the object browser. The two most important features that you will use visual basic toolbox and the various toolbars. . When you start a new project.4. you will learn about more advanced controls and how to add them to your project. you don¶t need to use all the different to write a visual basic application. As you work with visual basic. A variable declared as object is one that can subsequently be assigned(using the set statement) to refer to any actual object recognized by the application. try to use specific classes(such as textbox instead of control or. instead of using a variant or the generic object. a pop-up tooltip will appear. windows and other tools that help you create applications as quickly and easily as possible. many more controls come with visual basic 6.

As you resize your form.) Edit ± This toolbar contains items to assist you in editing your visual basic code. An application can have one or more forms. menus. The visual basic standard toolbar displays different buttons and changes its appearance as you use the different features of visual basic. the combined windows will act as though they are one window and will remain visible if you open any other windows. b. which contains your application¶s forms that you have been designed. and each form can have many controls that perform various functions. Visual basic has four default toolbars that can view or hide from the view. You can view the various properties of an object either in alphabetical order or by category. you already know much about the IDE. when you place the first text box control on a form. WORKING WITH THE IDE WINDOWS The IDE is really nothing more than a window program itself. So. You can also dock or undock the toolbars. status bars. You can resize the form window to make your windows whatever size is required. just get comfortable with the IDE and its windows.) Debug ± This toolbar contains items to assist you in finding errors in your code during a debugging session. You would then use the properties window to change this property to an appropriate name such as txtcustomer. THE PROPERTIES WINDOW The properties window enables you to change one or more properties the currently selected object. if you can work with the standard windows elements. its new size will displayed in the rightmost coordinates section of the standard toolbar. If you dock two or more windows together. Most programmers reconfigure . c. The highlighted object is usually a form or control. such as windows. its name property is set to Text 1 by default.) Form editor ± This toolbar assists you in adjusting you see under the menu bar at the top of your screen. THE FORM WINDOW You can use the window to design the different forms your application will contain. which means you can place them where you¶d like them onscreen as you work. Most of the visual basic windows are dockable and can be resized. Visual basicµs four default toolbars are :- a. Don¶t worry about designing form yet.CONTROLLING THE APPEARANCE OF THE TOOLBARS A toolbar is a collection of buttons that represent shortcuts to commonly used functions. For example. and the resizing buttons.

are displayed by visual basic to tell you what each icon means. you can only resize or move a control that has already been drawn on a form. Controls are prepackaged components that you reuse instead of writing them yourself. Tool tips are also displayed for many IDE features besides the toolbox. the toolbox always contains the pointer tool. and menus. The basic set of standard controls that always appear in the toolbox is described in ³forms. Although each development environment has its own default set of toolbox items. <arrow pointer>. Related items are listed together in a tree listing. EXPLAIN GENERAL CONTROLS OF TOOL BOX ? ANS:. applets.e. ActiveX controls. STANDARD TOOLBOX CONTROLS 1. Notice the box named data displayed at the bottom when the mouse printer (i.The toolbox window contains all the components that are available to use in your project. controls. user documents and property pages for an application. modules. the white arrow) rests on the data control these boxed descriptions. If you have an application with multiple forms. The set of controls available in the toolbox can be customized for each project. .this helps you write programs faster. user controls. called tool tips. you will probably be working on only forms and code modules.´ The toolbox contains controls used to customize forms. You can use the pointer to resize or move a control that has been drawn on a form. Pointer ± used to interact with the controls on the form (i. using the form layout window to align them properly on screen can be easier than setting their properties by hand. forms. objects. Any given control must be in the toolbox before you can add it to a form in the project. The three buttons on the project window enable you to display the code or the object (commonly the form)..or toggle the folders setting to group or ungroup the related objects.). Although the project window can display the various projects. Q. move them. and text based on the designer or editor is active.their work spaces to make the properties window larger than the default to speed access to various items in the properties window. The toolbox displays design-time controls. THE PROJECT WINDOW You use the project window to manage the various components or files of your project. etc. resize them.e. The pointer is not a control.5.. THE FORM LAYOUT WINDOW The form layout window enables you to preview the final location on the screen where the form you are working with will appear. When you select the pointer. HTML scraps.

DriveListbox ± A control for accessing the system disk drives (C:. That is. 14. 4.). The image control does not provide as many capabilities as a picturebox. oval. Picture box ± A control that displays a graphical images (either decorative or active). Listbox ± A control that provides a list of items. as a container that receives output from graphics methods. the user creates box which can easily choose to indicate if something is true or false. That is. DirListbox ± A control for accessing directories on a system. Image ± a control for displaying images. Textboxes can also display text. Label ± A control that displays uneditable text to the user. FileListbox ± A control for accessing files in a directory. etc. such as a caption under a graphic. 12. The user can either choose an item from the list or enter a value in the text box. The user presses or clicks to initiate an action. It provides a graphical tool for quickly navigating through a long list of items or a large amount of information. 6. draw the frame first. A:. or to display multiple choices when the user can choose more than one. 15. or circle. for indicating the current position on a scale. or as an input device or indicator of speed or quantity. for indicating the current position on a scale. Timer ± A control that performs a task at programmer-specified intervals. 18. 10. It provides a graphical tool for quickly navigating through a long list of items or a large amount of information. and then draw controls inside the frame. a list of items from which the user can choose one. Also. 5. 7. To group controls. square. Shape ± Allows you to draw a variety of shapes on your form at design time. 8. Frame ± A control for grouping other controls. Displays a graphical image from a bitmap. VScrollBar ± A vertical scollbar. 13. Also. or as an input device or indicator of speed or quantity. the user creates a button the user can choose to carry out a command. That is. Command button ± A control that represents a button. or metafile . 9. allows you to create a graphical or functional grouping for controls. or as a container for other controls. Checkbox ± a control that provides the user with a toggle choice (checked or unchecked). The list can be scrolled if it has more items than can be displayed at one time. 11. icon. rounded rectangle. Line ± A control for drawing lines. Allows you to have text that you don¶t want the user to change. 3. 16. Combobox ± A control that provides a short list of items which allows you to draw a combination list box and text box. rounded square. holds text that the user can either enter or change. You can choose a rectangle. That is. A timer is not visible to the user. Textbox ± A control for accepting user input. HScollBar ± A horizontal scrollbar. 17. this controls is invisible at run time.2.

Data ± A control for connection to a database. . 20. 19. OLE ± A control for interacting with other windows applications which allows you to link and embed objects from other applications in your visual basic applications. Images displayed in an image control can only be decorative and use fewer resources than a picture box.on your form.