Page 1 :
Department of Computer Science, GFGC, Malur, Visual Programming-Vl, (Solved 2019 Question Paper), SECTION-A, Answer any ten questions:, 1.What is visual programming language? Write any two features of VB., Ans: Visual Programming Language(VPL) is a programming language that uses graphical elements, and figures to develop a program graphically rather than by specifying them textually., • Debugging, • Object Oriented, 2. Explain Immediate Window., Ans: The Immediate window can be used during design time , it is primarily used in Break mode., When you type a statement into the immediate window and press the enter key, the statement is, executed once. To navigate the immediate window , From the view menu of the Visual Basic Editor,, choose Immediate window., 3. What is Variant data type? Explain with suitable example., • The variant data type can store numeric, data/time or string data., • The default visual basic data types are variant data type., Example:, Type, Description, Size, Range, Varient(with number), 16 bytes, Any numeric value up, to the range of double, Varient(with Character), 22bytes + string length 0 to approximately 2, billion, 4.Explain option button Write any two properties of option button., Ans: option buttons are used for choices where only one choice in a group is allowed., Property, Description, Name, To change of the name of the object ., Font, Sets font type, style, size., 5. Distinguish between image and picture., Sl.No., Picture Box, Image Box, 1, Having auto size property, Not having auto size property, 2, Occupies more memory, Occupies less memory, 3, Not having stretch property, Having stretch property, 4, Editing picture is possible, Editing picture is not possible, 6. Explain Dim and Rem statement., Ans: Dim statement: Declares and allocates storage space for one or more variables ., Syntax: Dim [with events] variable list, Rem statement: The rem statement must be the last statement on the line., If it follows another statement; the rem must be separated from that statement by a space., Syntax: Rem comment, 7. Distinguish between Implicit and Explicit variable., Implicit variable, Explicit variable, Implicit through not plainly expressed, Started clearly and indetail, leaving no room for, confusion or doubt, Var lstInteger=new List<int>();, List<int>lstInteger=newList<int>();, 8. Explain the difference between the Exit and End statement., Exit, End, The exit is used for abnormal termination, The end statement is the last line of the program, or function, Exit statement allows you to permanently exit, The stop or return statement are used for normal, from the block of statements from loop, termination, 9. What is dynamic array? Explain., 1
Page 2 :
Department of Computer Science, GFGC, Malur, Ans: Dynamic array are those arrays which are allocated memory at the run time with the help of, heap. Thus dynamic array can change its size during run time., Syntax: Dim Arrayname() As Integer, ReDim Arrayname(Size) As Integer, Example: Dim list() As Integer, ReDim list(5) As Integer, 10. What is splitter window? Mention types of splitter window., Ans: A splitter window is a way to split the screen into two or more different pans., Types of splitter window, • Static splitter window, • Dynamic splitter window, 11. Define Serialization. Name the three classes used in MFC Serialization., Ans: Serialization is the method used by MFC to store an object to a file or another type of storage., Three classes:, • CFile, • CObject, • CArchive, 12. Define OLE. Give two features of OLE., Ans: Object Linking and Embedding(OLE) is a compound document standard developed by, Microsoft corporation. It enables you to create objects with one application and then link or embed, them in second application., Features:, • Linking and Embedding, • Uniform Data Transfer, SECTION-B, Answer any five questions., 13. (a) Write a note on Visual basic IDE., (b) Explain Different types of controls used in visual basic., Ans: a. A visual basic window is also called integrated development environment (IDE) window., This window open when we click on standard exe icon from new project dialog box. In visual basic, a, program is referred to as a project. Every visual basic project consists of at list two separate files, called a project file and a form file. A project file which extension is .VBP and form file which, extension is .FRM., • Title Bar, • Menu Bar, • Tool Bar, • Tool Box, • Form Window, •, Project Explorer Window, • Properties Window, •, Form Layout Window, , 2
Page 3 :
Department of Computer Science, GFGC, Malur, , Title Bar: A title bar is the horizontal bar located the top of the screen. It includes the project name,, an icon that closes visual basic at the left and icon that minimize the group window, change the size of, the group or close visual basic on right. This component common for all window application., Menu Bar: The menu bar is also common for all document window. It contents command required, and build an application. The main menu items have some menu items that can be chosen when, needed., Tool Bar: The tool bars gives us quick access to commonly used menu command. Beside the main, tool bar, which is displays by default window the menu bar, visual basic IDE provides additional tool, bar for specific purpose. The four built in tool bar are standard, edit, debug and from editor. By, default, standard tool bar appear immediately below the menu bar., Tool Box: The tool box contains the icon of the control we can place on a form to create the, application’s user interface. By default tool box contains a pointer icon and twenty other icon of, ActiveX controls. The tool box appear at the left side on screen by default. User can change its, position anywhere on the form. Even tool box can be turn off on screen. To place a control on a form,, we first select it with a mouse and then move the mouse over the form. When the mouse is over the, form, the curser turns into a large plus sign, and we can draw control on the form., Form Window: A form window used in visual basic to create project inside the form. A form, window appear on screen just like grid of dots inform of matrix. We can increase or decrease size of, form window according to our need. By default only one form window will appear on screen but, more than one form window can be open on the project window., Project Explorer window: The docked on the right side of the screen and just below standard tool, bar, is the project explorer window. The project explorer window holds the file name for the file, included in our project. A window’s title bar holds the name our project with .VBP file extension,, which is project one by default until we save it with a new name., Properties window: The properties window is docked under the project explorer window. The, properties window allows us to assign or change properties associated with a particular object., Properties are attributes such as size, position etc. like a form, each control has its own set of, properties., Form Layout window: The form layout window specifies a form’s position on the screen at run time., The form layout window appear below the properties window. It consist of an image representing the, screen and the form’s relative position on the screen., b. Types of controls used in Visual Basic, • Intrinsic Control, • ActiveX Control, • Insertable Objects, Intrinsic Control:, 3
Page 4 :
Department of Computer Science, GFGC, Malur, •, •, •, , The built in Visual basic controls is called intrinsic control., All intrinsic controls will show up in the Tool Box., They are inside the visual basic with .exe file name extension., , ActiveX Control: The ActiveX control as separate files with a .ocx file name extension. These, include controls that are available in all editions of visual basic and those that are available only in the, professional and enterprise editions(such as Listview, Toolbar, Animation, and Tabbed Dialog)., Example:, Common Dialog, CMDLG32.OCX, Automatically installed, DataComboBox, MSDATLST.OCX, Automatically installed, DataList, MSDATLST.OCX, Automatically installed, MSFlexGrid, MSFLXGRD.OCX, Automatically installed, Insertable objects: Insertable objects can be added to the toolbox, so they can be considered, controls. For example, like the Excel Worksheet object; with a list of the employees, or a project, Calendar object having the scheduling information for a project., 14. (a) Distinguish between Combo box and List box., (b) Explain the scroll bar control with suitable example., Ans. a., Sl.No, List Box, Combo Box, 1, List box displayed multiple items., Combo box displayed single item., 2, In the list box we can only select item., In combo box we can write/search and select, item., 3, List box is only listed items box., Combo box is combination of textbox listbox., 4, In the list box we have scroll down and In the Combo box we have only dropdown, scroll up facility., facilities., 5, Check box can be used within a list box. Check box cannot be used within a combo box., 6, List box is much easier to handle., Combo box is not easier as well as list box to, handle., 7, Can’t add image item in list box., Can add image item in combo box., 8, List box have 2 styles:, Combo box have 3 styles:, 0- Standard, 0- Dropdown combo, 1- Checkbox, 1- Simple combo, 2- Dropdown list, , b. The ScrollBar is a commonly used control, which enables the user to select a value by positioning, it at the desired location. It represents a set of values. The Min and Max property represents the, , 4
Page 5 :
Department of Computer Science, GFGC, Malur, minimum and maximum value. The value property of the ScrollBar represents its current value, that, may be any integer between minimum and maximum values assigned., The scroll bar controls display Vertical and Horizontal scroll bar on the form. This is used for, navigating through large amount of information., These are the two types of scroll bar controls:, 1. Horizontal scrollbar, 2. Vertical scrollbar, Horizontal scrollbar: The Horizontal Scroll Bar is widely used in windows applications. Scroll bars, provide a way to move through a list of information and make great input devices. The appearance of, a Horizontal scroll bar is shown in following figure., , Clicking on End Arrow increments the scroll box a small amount, clicking the Bar Area increment the, scroll box a large amount ,and dragging the scroll box provides continuous motion., Properties used in the scroll bar:, Name, max, min, Large change, Small change, value., Event: Change., Vertical scrollbar: The vertical scroll bar is widely used in windows applications. Scroll bars provide, a way to move through a list of information and make great input devices. The appearance of a, Vertical scroll bar is shown in following figure., , Clicking on End Arrow increments the scroll box a small amount, clicking the Bar Area increment the, scroll box a large amount ,and dragging the scroll box provides continuous motion., Properties used in the scroll bar:, Name, max, min, Large change, Small change, value., Event: Change., Example: Design the form, set the property as follows and execute the program;, Object, Text 1, , Properties, Name, Text, Font size, , Values, Txtvalue, 14, 5
Page 6 :
Department of Computer Science, GFGC, Malur, HScroll 1, , Name, Change, , VScroll 1, , Name, Change, , HScroll, Private sub HScroll_Change(), txtvalue .Text=HScroll1.Value, End Sub, 14, Private sub VScroll_Change(), Txtvalue.Text=VScroll_Value, End Sub, , 15. (a) Define scope of Variable. Explain the different levels of scope in VB Application., (b). Explain the branching statement used in VB., Ans: a. The term Scope refers to whether the variable is available outside the procedure in which it, appears.yhe Scope is procedure-level or module-level., A variable declared with Dim at the beginning of a procedure is only available in that procedure., There are three levels in Scope in Vb application:, 1. Procedure Level Scope, 2. Module Level Scope, 3. Global Level Scope, Procedure Level Scope : Also called as Local Variables, all Procedure-Level variables are accessible, only within the procedure or Function in which they are declared. As soon as the procedure finishes,, the variable lost its scope., For example: In the following code the Variable total is only accessible to code within the procedure., , Module Level Variable: All Procedure-Level variables are accessible only within the Module in, which they are declared. These are variables that are declared outside the Procedure itself at the very, top of any Module. Its value is retained unless the Workbook closes or an End Statement is used., Example:, , 6
Page 7 :
Department of Computer Science, GFGC, Malur, , Global Level Scope: All Global-Level variables are accessible in anywhere in the Project (.i.e; in any, Module, User Form, Classes) within the Workbook in which they are declared. And also accessible to, outside of this project or workbook. These are variables that are declared using ‘Public’ keyword at, the very top of any Public Module ., Example:, , b. An application needs a built-in capability to test conditions and take a different course of action, depending on the outcome of the test., Visual Basic supports following branching statements:, I., If Statement, II., Select Case Statement, If Statement: The statement evaluate the expression first, and the depending on expression value the, statement are executed. If expression value is either true or false., Visual Basic supports the following if Statement:, • If..Then..End If Statement, • If..Then..Else..End If Statement, • Nested If Statement, • If..Than..ElseIf..End If Statement, If..Then..End If Statement: Only when condition is true statement will executed ,otherwise the, action is skipped., Syntax: If<condition> Then, Statement, End If, Flow Chart:, , 7
Page 9 :
Department of Computer Science, GFGC, Malur, , •, •, •, , Select Case Statement :, It is also for multiway decision making statement., If the index value and case no is same (equal) statement1 will be executed, otherwise it will, check for index no and case1 if both case no and index no is same statement2 will be, executed., • If none of case no and index no is statement-n will ’n’ executed., Syntax: Select case Index, Case 0, Statement 1, Case 1, Statement 2, Case else, Statement n, End Select, Flow Chart:, , 16. (a) Using-Case Statement, write a VB Program to perform all the arithmetic operation., (b) Distinguish between SDI and MDI application., Ans: a., Object, Property, Values, Label1, Name, lblfirst, Caption, Enter first number, Label2, Name, lblsecond, 9
Page 10 :
Department of Computer Science, GFGC, Malur, , Label3, Label4, Text1, Text2, Text3, Command1, , Caption, Name, Caption, Name, Name, Name, Name, Name, Caption, , Enter second number, lblchoice, Enter your choice, lblresult, txtfirst, txtsecond, txtchoice, cmdresult, Execute, , Private sub cmdresult_Click (), DIM a As Integer, DIM b As Integer, DIM c As Integer, DIM chAs Integer, a = val(txtfirst.Text), b= val(txtsecond.Text), ch = val(txtchoice.Text), Select Case(ch), Case 1, c=a+b, lblresult.Caption = “addition=” & c, Case 2, c=a-b, lblresult.Caption = “subtraction=” & c, Case 3, c = a* b, lblresult.Caption = “multiplication=” & c, Case 4, c=a/b, lblresult.Caption = “division=” & c, Case Else, lblresult.Caption = “invalid choice”, End Select, End sub, OUTPUT:, , b., MDI, Multiple Document Interface, We can open multiple documents, simultaneously, , SDI, Single Document Interface, We can open onlymone document at a time, , 10
Page 11 :
Department of Computer Science, GFGC, Malur, All the documents can be maximized in the, There needs to be a special command in order to, MDI, maximize the documents., MDI is a Container control, SDI not Container control, MDI holds 5 classes, SDI app golds only 4 classes, (CChildWnd-CMDIChildWnd, CDoc, Cview, (C View, CDoc, Underframe, CWinApp), CFrameWnd), MDI is when your application consists of an, SDI is stand-alone, ordinary windows/forms that, MDI parent-form that contains all the other, exist independently of each other., windows/forms., Latest web browsers., windows notepad, 17.(a) Write a note on Common dialog box Control., (b) Explain progress bar Control with an example., Ans:a., The Common Dialog control provides a standard set of dialog boxes for operations such as opening,, saving, and printing files, as well as selecting colors and fonts and displaying help. Any six of the, different dialog boxes can be displayed with just one Common Dialog control. A particular dialog, box is displayed by using one of the six "Show..." methods of the Common Dialog control:, • ShowOpen, • ShowSave, • ShowPrinter, • ShowColor, • ShowFont, • ShowHelp, The Common Dialog control not an intrinsic control; rather, it is an "Active X" control that must be, added to the toolbox via the Components dialog box, as shown below. This dialog box is accessed, via the Project menu, Components item. Once you check "Microsoft Common Dialog Control 6.0", and click OK, the control is added to your toolbox (also shown below, circled). Then you can doubleclick it to make it appear on your form, as you would with any other control. The Common Dialog, control is not visible at run-time., , b, ShowOpen: Used to display the dialog to open file using Common dialog control., ShowSave: Opens “save as” dialog box. That provides the user a mechanism for specifying the name, of a file to save., ShowPrint: Used to print the opened files., ShowColor: Used to display the color in dialog box.(used to determine which color was selected)., ShowFont: Used display list of fonts that are available., ShowHelp: Used to display windows helpfile., Example:, , 11
Page 13 :
Department of Computer Science, GFGC, Malur, , The following table shows the common properties of a Progress Bar:, Property, Description, Appearance, Appearance of the object, Name, To change the name of the object., min, To set the minimum value., Max, To set the maximum value., Example:, Object, Property, Values, Label1, Name, Label1, Caption, Loading Project, Timer1, Name, Timer1, Interval, 500, Progressbar1, Name, Progressbar1, , Private sub DTPicker1_Click(), Text.Text =mDTPicker.Value, Text2.text = Formate(DTPicker1.Value, “dd-mm-yyyy), MsgBox "Installation is completed successfully", End Sub, OUTPUT:, , 18. (a)Write a note on OLE control., , 13
Page 14 :
Department of Computer Science, GFGC, Malur, (b).Write a VB program to validate the Username and Passwor, stored in, database, and display an appropriate message(use data control)., Ans: a. Object Linking and Embeddingis a comppound document standerd developed by microsoft, corporation. It enables you to create objects with one appilication and then link or embed them in a, second application. Embedded objects retain their original formate and links to the application that, creatted them., An OLE object may display as an icon. Double clicking the icon opens the associated object, application or asks the user to select an application for object eidting., OLE-Supported software applications include:, • MicroSofrt windows application,such as Excel, word and powerpoint, • Corel Wordperfect, • Adobe acrobat, • AutoCAD, • Multimedia applications, like photos, audio/vidio clips and powerpoint presentations., The following example shows how to embed a MixroSoft Excel object into a MicroSoft Word, document. Word is the container and Excel is the server., STEP1: Open Microsoft word document with some text written in the windows., STEP2: From insert menu , select object menu item.The object dialog box will appear as shown in, below:, STEP3: Choose Microsoft Excel as the object to embed as shown in below:, STEP4: Click on the word document to return to Microsoft word , and close the application. Thus an, Excel has been embedded in the word document.This object can be edited by double clikking on the, objrect., b., Object, Properties, Value, Label1, Name, Label1, Caption, User name and password, Label2, Name, Label2, Caption, Username, Label3, Name, Label3, Caption, Password, Text1, Name, Txtuser, Text2, Name, Txtpass, Passwordchar, *, Command1, Name, Cmdvalidate, Caption, Validate, Command2, Name, Cmdexit, Caption, Exit, Adodc1, Name, Adodc1, Caption, Username/Password, NOTE: Create database using(add-Ins ->visual data manager) with the fields(uname, password) and, will be stored in tabel name (Login)., Place the ADO data contol on form. Set the connection string property and the Record source property, of ADO data control., , 14
Page 15 :
Department of Computer Science, GFGC, Malur, , Private sub Cmdvalidate_Click(), Dim x As Integer, X=0, Adodc1.Recordset.MoveFirst, Do While not adodc1.Recordset.EOF, If txtuser.Text = adodc1.Recordset.Fields(0) and txtpass.Text = adodc1.Recordset.Fields(1) Then, MsgBox(“Valid User Name and Password”), X=1, End If, Adodc1.Recordset.MoveNext, Loop, If x=0 Then, MsgBox(“invalid username or password”), txtuser.Text= “”, txtpass.Text= “”, txtuser.SetFocus, End If, End Sub, Private sub Cmdexit_Click(), End, End Sub, OUTPUT:, , 19. (a) What is Menu editor? Write the steps to create menu using menu editor., (b) Explain Dataware controls., Ans: aVisual Basic Provides the menu Editor to design Menues and attach them to the forms of the, appliaction. The Menu Editor contains menu description tools that let you create the application’s, menu bar,menu commands and shortcut access keys., To create a list of menu commands on a form, 1 Click the form itself (not an object on the form)., 2 On the Visual Basic toolbar, click the Menu Editor icon, or select Menu Editor from the Tools, menu., , 15
Page 16 :
Department of Computer Science, GFGC, Malur, 3, 4, 5, 6, 7, 8, , 9, , 3. In the Caption text box, type the menu caption (the name that will appear on the menu bar),, and then press TAB., In the Name text box, type the menu name (the name the menu has in the program code). By, convention, programmers use the mnu object name prefix to identify both menus and menu, commands., To add the menu to your program menu bar, click Next. The Menu Editor clears the dialog, box for the next menu item. As you build your menus, the structure of the menus and, commands appear at the bottom of the dialog box., In the Caption text box, type the caption of your first menu command., Press tab, and then type the object name of the command in the Name text box., With this first command highlighted in the menu list box, click the right arrow button in, theMenu Editor. In the Menu list box, the command moves one indent (four spaces) to the, right. Click the right arrow button in the Menu Editor dialog box to move items to the right,, and click the left arrow button to move items to the left., Click Next, and then continue to add commands to your menu., , b.Data_Aware controls (Data-Bounds controls) is divided into following:, • DBList control, • DBCombo control, • Data Grid control, • DataList Box:, The first bound data custom tool is the DataList Box. The list box is automatically filled with a field, from a specified data control. Selections from the list box can then be used to update another field, from the same data control or, optionally, used to update a field from another data control., Some properties of the DataList box are:, DataSource - Name of data control that is updated by the selection., DataField - Name of field updated in Recordset specified by DataSource., RowSource - Name of data control used as source of items in list box., ListField - Name of field in Recordset specified by RowSource used to fill list box., BoundColumn - Name of field in Recordset specified by RowSource to be passed to DataField, once, selection is made. This is usually the same as ListField., BoundText - Text value of BoundColumn field. This is the value passed to DataField property., Text - Text value of selected item in list. Usually the same as BoundText., • DataCombo Box:, The DataCombo Box is nearly identical to the DataListbox, hence we won’t look at a separate set of, properties. The only differences between the two tools is that, with the DataCombo box, the list, portion appears as a drop-down box and the user is given the opportunity to change the contents of the, returned Text property., 16
Page 17 :
Department of Computer Science, GFGC, Malur, • DataGrid Tool:, The DataGrid tool is, by far, the most useful of the custom data bound tools. It can display an entire, database table, referenced by a data control. The table can then be edited as desired., The DataGrid control is in a class by itself, when considering its capabilities. It is essentially a, separate, highly functional program. The only property we’ll be concerned with is, the DataSource property, which, as always, identifies the table associated with the respective data, control. Refer to the Visual Basic Programmer’s Guide and other references for complete details on, using the DataGrid control., As an example of the power of the DataGrid control, here’s what is obtained by simply setting, the DataSource property to the dtaExample data control, which is bound to the Titles table in, the BIBLIO.MDB database:, , 20.(a) Write a note on DLL., (b) Explain document view architecture of MFC., Ans: a.DLL(Dynamic Link Libraries) is an executable file that acts as a shared library of funtions and, resources. Dynamic linking enables an executable to call functions or use resources stored in a, separate files. These functions and resources can be compiled and deplied from the executable that, use them., Steps to create DLL command:, Step1:start visual basic., Step2:From any project dialog box select the Active x control as shown below, , Step3:Select open it display the used control one dialog box design the Active x control., Step4: Change the project name as addition and write the code in the command button as shown, below., Text3.text = val(text1.text) + val(text2.text), Step5: Create a directry with name DLL from the file menu select make .ocx and store into the DLL, directry ., Step6: Save the project and form in to DLL directry., Step7: Close the project., b.The MFC document /view architecture includes a combination of a document, in which data is, stored and a view,in which has privileged space assea to the data., MFC support two types of document/view applications:, • Single Document Interface(SDI): it suppotrs only one open document at a time., • Multiple Document Interface(MDI):it allows user to open two or more documents, simultaneously. MDI supports multiple document types., 17
Page 18 :
Department of Computer Science, GFGC, Malur, Consider the document /view architecture that visual C++ uses for creating SDI applications. When, you create an SDI application,more clasess are created for an SDI application that for a dialog-style, application. Each of these clasess serves a specific purpose in how SDI applications operate. Ignoring, the about window dialog class, four specific classes makeup an SDI application:, • The CWinApp-derived class, • The CFrameView-derived class, • The CDocument-derived class, • The CView-derived class, Allfour these clasess work together to makeup the full functionality of an SDI application as shown in, the following figure., , 18