Questions and Answers s7

Total Page:16

File Type:pdf, Size:1020Kb

Questions and Answers s7

VISUAL BASIC QUESTIONS AND ANSWERS

Unit 1: Introduction Visual Basic: What is VB? – Event & Event procedures- Object-related concepts- VB program development process – Required computer skills – Logical program organization – VB program components – VB environment . VB fundamentals: Numeric, string constants, variables – data types & declaration – Operators and expressions- hierarchy of operations – inserting parenthesis – special rules concerning numeric expressions – string expression- assigning values to variables- displaying out- library functions – branching with If-Then, If-Then- else blocks- selection Select-Case- looping with For-Next , Do-Loop, While-Wend, Stop statement. 1)Difference between listbox and combo box? A LISTBOX CONTROL displays a list of items from which the user can select one or more. If the number of items exceeds the number that can be displayed, a scroll bar is automatically added to the ListBox control. A COMBOX CONTROL combines the features of a text box and a list box. This control allows the user to select an item either by typing text into the combo box, or by selecting it from the list. DIFF::Generally, a combo box is appropriate when there is a list of suggested choices, and a list box is appropriate when you want to limit input to what is on the list. A combo box contains an edit field, so choices not on the list can be typed in this field. 2)Difference Object and Class? Classes and objects are separate but related concepts. Every object belongs to a class and every class contains one or more related objects. 1)A Class is static. All of the attributes of a class are fixed before,during, and after the execution of a program. The attributes of a class don't change.The class to which an object belongs is also (usually) static. If a particular object belongs to a certain class at the time that it is created then it almost certainly will still belong to that class right up until the time that it is destroyed. 2)An Object on the other hand has a limited lifespan. Objects are created and eventually destroyed. Also during that lifetime, the attributes of the object may undergo significant change.So basically the difference between a class and an object is that a class is a general concept while objects are the specific and real instances that embody that concept. When creating an object oriented program we define the classes and the relationships between the classes . We then execute the program to create, update, and destroy the objects which are the specific realization of these classes. 3)Difference Declaration and Instantiation an object? Dim obj as OBJ.CLASS with either Set obj = New OBJ.CLASS or Set obj = CreateObject(?OBJ.CLASS?) or Set obj = GetObject( ,? OBJ.CLASS?) or Dim obj as New OBJ.CLASS Set object = Nothing ensure the object is release from the memory. If this object is a form, you can add set myform = nothing and Form_Unload() event.Maintain a habit of remove the object by using set object = nothing which will benefit at last. Visual Basic is supposed to automatically release objects when they go out of scope. To free up some memory usage, you can set the object to nothing. 4)How to set a shortcut key for label? object.KeyLabel(keycode) [= string] You would probably create the menu item as follows: .Add "keyFile", , , "E&xit", , vbAltMask + vbCtrlMask, vbKeyEnd The default key label for vbKeyEnd is "End". Thus, the shortcut string will be created by default as "Ctrl+Alt+End". 5)What is the size of the variant data type? The Variant data type has a numeric storage size of 16 bytes and can contain data up to the range of a Decimal, or a character storage size of 22 bytes (plus string length), and can store any character text. 6)What is the max size allowed for Msgbox Prompt and Input Box? 1024 7)Max label caption length. ? 2,048 8)Max Text box length ? 32,000 9)Max Control Names length ? 255. 10)Extension in Visual Basic Frm, bas, cls, res, vbx, ocx, frx, vbp, exe 11)What is frx? When some controls like grid and third party control placed in our application then it will create frx in run time. 12)Name some date function Dateadd(), Datediff(), Datepart(), Cdate() 13)Diff type of Datatypes? LOB (Large Object Data type). CLOB (Stores Character Objects). BLOB ( Store Binary Objects such as Graphic, Video Chips and Sound files). BFILE(Store file pointers to LOB It may Contain filename for photo?s store on CD_ROM). 14.What is Dll? Libraries of procedure external to the application but can be called from the application. 15)What are the scope of the class? Public , private, Friend 16)What are the Style properties of List Box? Simple ?Single Select , Extended. ? Multiple Select. 17)What are the different types of Dialog Box? Predefined, Custom, User Defined. 18)How to check the condition in Msgbox? If(Msgbox("Do you want to delete this Record",VbYesNo)=VbYes)Then End if 19)What are the Technologies for Accessing Database from Visual Basic? DAO, Data Control, RDO, ODBCDIRECT, ADO, ODBC API 20)What are the two major component within the visual basic programming development system? ->project file, form file. 21)what is an event? What is an event procedure? ->VB is based on event driven paradigm. When activated only when the user responds to a corresponding object. The program response to a action taken by a user is referred to as an event. 22)what is form? -> in VB window is called form.. the form consist of menu bar, status bar, title bar. 23)what are controls? ->the icon with which the user interact is called as control. 24)what is object? ->forms and controls are referred to collectively as object. 25)what are the properties of vb/ ->the object include properties which generally defines their appearance or behavior. 26)what are the VB program development process? ->different steps. 1-decide what the program is supposed to do. 2-create user interface include 2 steps a)draw the control. B)define the properties. 3- write VB instruction. Writing the commands called a event procedure. 4-run the program. 5-repeate one or more steps. 27) what are the required computer skills in vb. ->1-familarity with Microsoft windows o/s. 2-managing files with in windows 3-installing new application. 28) how we can save a VB project? -> save multiple files Choose save project as from file menu. Click save project button. 29) what are numeric constant? ->numbers are referred to as numeric constant. 30)what are the rules of numeric constant? ->*commas cannot appear anywhere in numeric constant. *constant can be preceded by +ve or –ve sign *integer cannot occupy two bytes. *long range integer occupy four bytes. 30)what is the range fallen in integer? -> -32768 to 32767 31) what is the range fallen in long range integer? ->-2147483648 to 2147483647 32) how many bytes does single and double precious real constant occupy.? ->4 bytes and 8 bytes. 33)what is string? ->string is a sequence of character enclosed in quotation mark. 34)what is a variable? ->a variable is a name that represent a numeric quantity, a string or some other basic data items.. 35)what are the rules of variables? -> *must begin with a letter, special data typing character are not permitted. *cannot exceed 255 character. *do not distinguish b/w uppercase and lowercase letter. 36)write the hierarchy of operations. *exponentiation *multiplication and division. *integer division. *integer remainder. *addition and subtraction. 37)Define the scope of Public, Private, Friend procedures? ->The set of public variables, methods, properties, and events described in a class module define the interface for an object. The interface consists of the object members that are available to a programmer who's using the object from code. You can create private variables, methods, properties, and events that are used by other procedures within the class module but are not part of the object's public interface. Additionally, constants user-defined types, and Declare statements within a class module must always be private. The Friend keyword makes a procedure private to the project: The procedure is available to any code running within the project, but it is not available to a referencing project. 38) Difference Declaration and Instantiation an object? Dim obj as OBJ.CLASS with either Set obj = New OBJ.CLASS or Set obj = CreateObject(?OBJ.CLASS?) or Set obj = GetObject( ,? OBJ.CLASS?) or Dim obj as New OBJ.CLASS Set object = Nothing ensure the object is release from the memory.If this object is a form, you can add set myform = nothing and Form_Unload() event.Maintain a habit of remove the object by using set object = nothing which will benefit at last. Visual Basic is supposed to automatically release objects when they go out of scope. To free up some memory usage, you can set the object to nothing. 39) What type of multi-threading does VB6 implement? Apartment model threading 40) What is the difference between a Picture Box and Image control? Image Control - Use this to display a picture. Use it over the Picture Box because it takes less operating system resources Picture Box- While it can display pictures, it also acts as an area on which you can print text and graphics. Use it for home-grown graphics or print previews 41) What is the size of the variant data type? The Variant data type has a numeric storage size of 16 bytes and can contain data up to the range of a Decimal, or a character storage size of 22 bytes (plus string length), and can store any character text. 42) What will be the result for 15/4 and 15\4 15/4 = 3.75 and 15\4 = 3 43) How many procedures are in VB? 2. function and sub procedures. Function Will return value but a sub procedure wont return values 44) What are the type of validation available in VB? Field, Form 45) What is the diff between the Create Object and Get object? Create Object - To create an instance of an object. Get Object ? To get the reference to an existing object. 46) Private Dim x as integer. Is it true? No. Private cannot be used in front of DIM. 47) What are the scope of the class? Public , private, Friend 48) What are the Style properties of List Box? Simple ,Single Select , Extended. ? Multiple Select. 49) What are the different types of Dialog Box? Predefined, Custom, User Defined. 50) Name some library functions in VB? -> abs , chr , cos, date , int , left , len , mid , sin , tan . 51)What is meant by selection? To execute the one of the several different blocks of statements , depending the value of expression. This process is known as selection. 52)What is branching? How does branching differ from selection? We can choose one of the two different paths, depending on the outcome of logical test., this process is known as selection. 53)What is looping? Many programs requires that a group of instructions be executed repeatedly, until some particular condition has been satisfied. This process is known as looping. 54)Name the six relational operators used in visual basic? The relational operators are: Equals = Not equals <> Less than < Greater than > Less than or equal to <= Greater than or equal to => 55)What is a logical expression? In additional to the relational operators, VB contains several logical operators. They are And, Or, Xor, Not, Eqv. 1. What are operands within a logical expression? The operands of the logical expressions are : And, Or, Xor, Not, Eqv. 2. What is the purpose of the IF Then statement? An IF Then block is use to execute a single statement or a block of statements on a conditional basis. Syntax: IF logical expression Then executable statement 3. What is the purpose of the IF Then Else block? An IF THEN ELSE statements are used in one of two different groups of executable statements to be executed , depending on the outcome of a logical test. Syntax: IF logical expression Then ……………………………………….. executable statement …………………………………………. Else ……………………………………….. executable statement …………………………………………. End If 55)How an IF Then Else block is ended? An IF Then Else block is ended with End IF statement because IF Then Else and End IF are separate statements that are used together to create a complete IF Then Else block. 56)What is the purpose of the select case structure? One way to select a block of statements from several competing blocks is to use a series of IF Then Else or IF Then Else IF Else blocks. If the number of block is greater than we use Select Case. Syntax: Select Case expression Case value 1 Executable expression Case value2 Executable expression ……………………………………………… Case else Executable statements End select 58)What type of application is the select case structure is well suited? The Select case structure I particularly convenient when used in conjunction with a menu entry. In such situation the selection is based upon the menu item that is chosen. 59) How are multiple data item is handled in a single case statement? The multiple data’s that can be handled by entering items and separated by the commas . 60) How is a range of data items handled in a Case statement? A Case statement may contain a range of strings, connected by the keyword To. 61) How is a logical expression is handled in a Case statement? The logical expression is preceded by the keyword IS. 62) What is a purpose of the For Next structure? The For Next structure is a block of statements that is used to carry out a looping ; that is , to execute a sequence of statements some predetermined number of times. Syntax: For index = value1 To value2 ……………………………………………… Executable statements ……………………………………………… Next index. 63)Summarize the rules for For-Next structure? The structure begins with a For-TO statements and ends with Next statements to be executed. It specify the number of passes through the loop. Within this statement, index is a variable whose value begin with value1, increase by 1 each time the loop is executed. 64)What is the purpose of the Exit For structure? When the Exit for statement is generally encountered during the execution of a program, control is immediately transferred out of the For Next loop , to the first executable statement following Next. 65)Describe the four variations of a Do Loop structure? The variations of the Do Loop structure are: First form: Do While logical expression …………………………………………. Executable statements ………………………………………….. Loop Second form: Do Until logical expression …………………………………………. Executable statements ………………………………………….. Loop. Third form: Do …………………………………………. Executable statements ………………………………………….. Loop While logical expression Fourth form: Do …………………………………………. Executable statements ………………………………………….. Loop Until logical expression 66)What is the syntax for Do While loop? Do While logical expression …………………………………………. Executable statements ………………………………………….. Loop 67)What is the purpose of the While Wend structure? It is used for permits conditional looping. Syntax: While logical expression ………………………………………. Executable statements ………………………………………. Wend. VISUAL BASIC QUESTIONS AND ANSWERS

UNIT 2: VB control fundamentals: control tools- control tool categories- working with controls- naming forms and controls- executing commands- displaying output- entering input data- selecting multiple features, exclusive alternatives, form from a list- assigning properties collectively- generating error message- creating tamed events- scroll bars. 1.What is the purpose of toolbox in the Visual Basic? It contains a collection of control tools, such as labels, text boxes, command buttons,……. These controls, together with the customized menus, allow us to build a broad variety of graphical interfaces. 2. What is are tools in the toolbox?

 Check box:

 Combo box:  Command button:

 Data

 Directory list box:

 Drive list box:

 File list box:

 Frame:

 Horizontal scroll bar:

 Image box:

 Label:

 Line:

 List box:

 OLE container:

 Option button:

 Picture box:

 Pointer:

 Shape:

 Text box:

 Timer:  Vertical scroll bar: 3.describe the two different methods for adding a control to the form design window? The two methods are: 1. By clicking on the desired control tool within the toolbox, then clicking on the control’s location within the form design window. 2. By double clicking on the desired control tool within the toolbox, automatically placing the control at the center of the form design window. 4.How is control relocated in the Form design Window? A control relocated in the Form design Window by dragging the control to its desired location. 5. How is control resized in the Form design Window? A control resized in the Form design Window by dragging one of its edges or corners. 6. How is control removed from the Form design Window? A control removed from the Form design Window by highlighting the control and the press delete key. 7. Describe, in the general terms that the default naming system used with visual basic controls within the form design window? When an object is added to the new form design window, in the general terms that the default naming system used with visual basic controls within the form design window. Each name includes a generic identifier that identifies the type of object, followed by a number that identifies the order in which that particular object type has been added to form design window. 8.under what condition is it generally advisable to override the default naming system used with visual basic controls? Microsoft suggest that the such programmer assigned name includes a three-letter prefix suggesting the type of objects. 9.how are value are assigned to visual basic control properties at design time? Design time assignments are made by selecting a property from the list of properties shown in the property window and then either choosing an appropriate value from the adjoining list of values or entering a value from the keyboard. These property values will apply when the application begins to run. 11. how are value are assigned to visual basic control properties at run time? Run time assignments are carried out using Visual Basic assignment commands. In general terms, a property assignment is written as: Object_name.property = value Where object name is refers to the name of the control, property refers to the associated property name and value refers to the assignable item, such as a number or a string. 12. What is an event procedure? An event procedure is an independent group of commands that is executed whenever an “event” occurs during a program execution. 13.what is a relationship between an event procedure and a command button? An event procedure is an independent group of commands that is executed whenever an “event” occurs during a program execution. Command buttons are often used to execute the Visual Basic event procedure. 15. what is the purpose of checkboxes? Many programs allow the user to select among many different option. That is , the user may select one option from the different options, or no options at all. Check boxes are used for it. 16.what is the use of option button? It is similar to the check boxes , but the difference is that in check boxes, the user can select only one option from the different options or no options at all. But option button will the user to select one or more than one option from the list of options. 17. what is the purpose of frame? Many application requires several different groups of option buttons., where the selection of an option button within the each group is independent of the selection made in other groups. This can be accomplished by placing each option- button group with a separate frames. 18. can checkbox can be placed in the frame? Usage of check boxes are not allowed in the frames because only the use of option buttons that can be used in the frames that is; Many application requires several different groups of option buttons., where the selection of an option button within the each group is independent of the selection made in other groups. This can be accomplished by placing each option- button group with a separate frame. 19.How do list box and combo box differ from each other? A list box o0ffers another approach to selecting among the several different alternatives. Each alternative can be identified as the single entry within list. When a program is executed , clicking on a list of entry will causes the value list of object to be assigned to the list index property. An If-Then- Else or a Select Case structure are used. Closely associated with a list box is the combo box, which is single control combining a text box and a list box. we must associate the event procedure in the combo box. We will use the structure Select Case here also. When program is executed , the combo box will show the title language in the text box area. 20.How are new items are added in the list box or combo box? Initial list enter is that can be entered as strings by clicking on a list entry will cause the value of list index to be assigned to the list index property. An if then else or select case structure also will carried out for this action. In order to enter more same process is done. This process is similar to the combo box also. 21.What is the property of with block? When assigning the values to several properties within the same object at run time, it is often convenient to do so using a with block Syntax: With object name

 Property 1=…………………………

 Property 2=…………………………

 …………………………………………….

 …………………………………………....

 Property=…………………………….. End with 22. What is the purpose of Msg box function? The Msg box function is convenient way to display error messages, as well as other type of information that may useful during the course of computation. This function is written as single statement: Msg Box (string) 23. for what types of applications is the timer control intended? The application involves timing events, such as digital clock or a stopwatch, make uses of the timer control. 24. when using the timer control, what is the purpose of interval property? The vales assigned to the certain timer properties are critical, however since they govern the functioning of the timed events. So the interval property has the importance in the timer control. The values used in the interval property are integer of range 0 to 65535. 25. What is the use of scroll bar? The scroll bar is used to view a large document by moving the visible window vertically or horizontally. VISUAL BASIC QUESTIONS AND ANSWERS UNIT 3: Menu & dialogue boxes- building drop-down menus- accessing menu from keyboard- menu enhancements- submenus- pop-up menus- dialogue boxes- more about Msg box – the input box functions. Executing and debugging a new project: syntax errors- logical errors- setting break points- define watch values- stepping through a program- user- induced errors- errors handlers- generating a stand-alone executable program.

1. What is the difference between a drop-down menu and pop-up menu? Drop down menu represent another important class of components in the user interface, complementing and in some case replacing the Visual Basic controls. A drop down menu will descend from the menu heading when the user clicks on the menu heading. Another frequently used menu type is the pop-up menu. A pop-up menu can appear anywhere in the form usually in response to clicking the right mouse button. 2. What is the purpose of menu editor? The menu editor includes other features that permit various menu item enhancements. 3. Within the menu editor what is the purpose of enabled check box? The useful feature of menu editor is that is the ability to deactivate a menu item by deselecting the enabled box. 4. Within the menu editor what is the purpose of visible check box? A menu item made invisible by deselecting the visible box. 5. Within the menu editor, what is the difference between caption and the name? The caption is actually the screen name of the item, as it appear in the menu bar or within the drop down menu. The name is used only in the Visual basic code – it is not displayed when the application is running. 6. Describe the order in which the various menu items are entered in the menu editor? All the menu components must be entered ;they are:

 The first menu heading.

 The corresponding menu items for the first menu.

 The second menu heading.

 The corresponding menu items for the second menu. 7. What is a keyboard access character? A keyword access character can be defined for each menu item. This allow user to view a drop down menu by pressing Alt and access key for the menu heading, rather than clicking on the menu heading. 8. What is keyboard shortcut? A keyword shortcut is typically a function key, or Ctrl-key combination or a Shit key combination, in addition to access the characters. 9. What is indicate by a check mark shown next to a menu item? a check mark shown next to a menu item indicates that on-off status of the menu item. 10. How a menu item is initially deactivated? The menu item is initially deactivated by deselecting the enabled box. 11. How is a separator included in a list of menu items? The items within a menu can be grouped together by introducing separators at various locations within a menu. Each separator is a menu item consisting only of a dash. 12. What is a purpose of submenu? A menu item may have a submenu associated with it. Placing the mouse over the menu item will cause the corresponding submenu to be displayed adjacent to the parent menu item. The submenu items may be assigned the same properties as any other menu item. The uses of submenu allow menu items to be arranged in the hierarchical or logical manner. 13. How pop-up menu is is created? A pop-up menu is created via the menu editor in the same manner as a drop-down menu, except that the main menu item is not visible. A event procedure must be entered into the code editor so that the pop-up menu appear to the response mouse click. 14. What is purpose of a dialog box? A dialog box is used to exchange information between the program and the user. It is a separate form that is generally accessed in response to a selection from a menu or a list. 15. How secondary form is added to an active project? A secondary form can be added to an active project via the load command; i.e. , Load form 16. How secondary form is added active project to removed? A form can be removed from an active project, thus freeing up memory, via the unload command; i.e. ; Unload form 17. What is a model form? The new form is displayed as a model form. That is the form will remain in place , preventing the activation of any other forms, until the user disposes of the form by accepting or rejecting it. 18. What is a purpose of Msg box function? The Msg box function is convenient way to display error messages, as well as other type of information that may useful during the course of computation. This function is written as single statement: MsgBox (string) 19. What is the general form of the Msgbox function? The general form of the MsgBox is : Integer variable = MsgBox (string, integer, title) 20. What is the purpose of the title arggument in a Msgbox function access? Title represent the string that will appear in the message box’s title bar. It’s default vale will be the project name. 21. What is the purpose of the Inputbox function? The input box is similar to the MsgBox function. The function is primarily intended to display a dialog box that accepts an input string , whereas the MsgBox is primarily intede to shown an output string. 22. What is the general form of an inputbox function access? The general form of input box function is: String variable= input box(prompt,title,default) 23. What is syntactic error? When do syntactic errors occur? What happens when a syntactic error is detected? Many different kind of errors can arise when creating and executing a new Visual Basic project like Syntactic error which occur when Visual Basic commands are written improperly. When syntactic error is detected the offending statement is highlighted within the Code Editor Window, and the nature of the error is explained within a message box. 24. Cite another commonly used name for syntactic error? Another commonly used name for syntactic error is Compiler error. 25 What is a logical error? When are logical error detected? How do logical errors differ from syntactic error? Many execution errors are caused by faulty program logic. Hence they are often referred to as logical errors. Logical errors are detected when the errors cause the program to “crash” during execution. Logical error cause during program execution while syntactic error cause during program compilation. 26. What happens when a logical error results in system crash? If a logical error results in system crash a message is produced indicating the reason for the crash, also the location of the error is flagged within the Code Window. 27 .What happens when a logical error occur during program execution but allows the program to execute normally without crashing? How is the occurrence of a logical error recognized under these conditions? Logical errors that produce incorrect results without a system crash can be difficult to find. However , the VB Debugger contains features that can assist in locating the source of errors. These features include Stepping through a program, setting break points and defining Watch values. 28. Describe three different ways to access the Visual Basic debugger? The three ways is: 1. Debug menu on the Main menu bar 2. Through certain function keys or 3. Through the Debug toolbar. 29. Describe the general strategy that is used to locate and identify the source of a logical error? The general strategy is to place a breakpoint near the suspected source of error. Then execute the program in the normal fashion, until the breakpoint is encountered. Then define one or more watch values and step through the program, one instruction at a time and observing it you can identify the error is located. Once location of the error is known the source of the error can be identified. 30. What is a breakpoint? Where are the breakpoints typically located within a VB program? How are the breakpoints identified when viewing the program listing? Breakpoints are which cause the execution of a program to be suspended. They are placed near to the suspected source of error. The breakpoint is identified in program list by selecting Toggle Breakpoint from debug menu. 31. Write three different methods for setting a breakpoint within a VB program? There are three different methods for setting a breakpoint, they are: 1. Select a Toggle Breakpoint from the Debug menu. 2. Click on the Toggle Breakpoint button within the Debug toolbar. 3. On an Intel-based computer, press function key f9. Once the breakpoint is set the statement will be clearly highlighted. 32. Suppose a break in the program execution occurs at a breakpoint. Does the break occur before or after the statement containing the breakpoint has been executed? The break in the program execution will occur just BEFORE the selected statement is executed. 33. Describe three different ways to remove a breakpoint? The breakpoint is removed the same way as it is been set, i.e. : 1. By selecting Toggle Breakpoint from the Debug menu. 2. By clicking on the Toggle Breakpoint button on the Debug toolbar. 3. Or by pressing function key f9. Thus the breakpoint feature is referred to as Toggle. 34. Suppose a program contains several different breakpoints. How can all of the breakpoints be removed at once? If a program contains several different breakpoints, it is removed all of them at once. By simply selecting Clear All Breakpoints from the Debug menu, of pressing function keys Ctrl-Shift-f9 simultaneously. 35. What is a temporary breakpoints? How is a temporary breakpoint set? How does a temporary breakpoint differ from an ordinary breakpoint? The temporary breakpoints are also defined by clicking on any point within the statement, and then either selecting Run to Cursor from the Debug menu or pressing function keys Ctrl- f8. Unlike a regular breakpoint, however which remains in place until it is toggled off, the temporary breakpoint becomes inactive after one program execution. 36. What is a watch value? Watch values are the current values of certain variables or expressions that are displayed at breakpoints. 37.What is the difference between an ordinary watch value, a quick value and an immediate watch value? Where does each type of watch value appear? Ordinary watch value are generally the most useful, because they remain active as you step through a program on a line- by-line basis. Now suppose a program has executed up to a breakpoint, and would like to know the current value of a variable or expression that has not been previously defined as a watch value by Quick Watch value. Whereas to determine the current value or expression at a breakpoint is to enter the variable/expression into the Immediate window. 38. How is the watches window opened within the Visual Basic environment? To open the Watches window, select Watch window from the View menu, or click on the Watch window button on the Debug toolbar. 39. Describe four different ways to add a variable or expression to the Watches window? The four different ways are: 1. Select ADD Watch..from the Debug menu and enter the required information in the Add Watch dialog box. 2. Right-click on the Watches window, select Add Watch…, and then enter the required information in the Add Watch dialog box. 3. Highlight an expression in the Code Editor Window and select Add Watch.. from the Debug menu. The highlighted expression will then in the Add Watch Dialog box. 4. Highlight an expression in the Code Editor Window. Then right-click and select Add Watch. The highlighted expression will appear automatically in the Add Watch dialog box. 40. What happens to existing watch values as you step through a program? As you step through a program beyond a breakpoint the current value of each watch value will be displayed within the Watches window. Thus the existing watch values would be removed or changes as you progress through each line of the program. 41.how is a watch value edited? How is a watch value removed? Existing watch variables and expressions can easily be edited or removed by right-clicking within the Watches window and then selecting Edit watch. Or Delete watch.. or by selecting Edit Watch from the Debug menu and then supplying the appropriate information to the Edit Watch Dialog box. 42. In what way is the quick watch feature useful when debugging a program that already has several watch values defined? While debugging a program, your program has executed up to breakpoint and needs to know the current value of a variable or expression that has not been previously defined, the quick watch value highlights the current variable or expression. 43. Describe three different ways to access the quick watch feature? The three different ways are: 1. Select Quick Watch from the Debug menu. 2. Press the function keys Shift-f9 simultaneously. 3. Click on the Quick Watch button within the debug toolbar. 44. How does a quick watch value differ from an ordinary watch value? In ordinary watch value, if a command cause a variable or expression to change its value , the change is seen as it happens whereas are not updated as you progress through the program on a step-by-step basis. 45. How does a quick watch value converted to an ordinary watch value? Why might you want to do this? To convert a quick watch value to an ordinary watch value, you should just click on the Add button within the Quick Watch dialog box. This is done to update the watch values as you step through a program. 46. What type of information can be obtained from the immediate window at a break point? How is this information obtained? The current value or expression will be displayed within the Visual Basic environment. It is obtained by typing a question mark (?) followed by the variable. For example to determine the value of the variable r at a breakpoint, simply type “?r”. 47. Describe the three different ways to display the Immediate window if it is not already shown? Ans. If the Immediate window is not present it is displayed in any of the following ways: 1. Select immediate window from the View menu. 2. Press function keys Ctrl+ G simultaneously. 3. Click on the Immediate window button within the Debug toolbar. 48. What is the difference between Step into, Step over, and Step our? When would each be used? A Step Into results in line-by-line stepping within the current procedure , and any subordinate procedures that are accessed by the current procedure. In Step Over results in line-by-line stepping within through any subordinate procedures that are accessed along the way. In Step Out results in execution of all remaining statements within the current procedure, and then pauses the first statement following the procedure access in the parent routine. 49. Describe three different ways to step through a program beyond a breakpoint using Step Into, Step Over and Step Out? Step Into, Step Over, Step Out: 1. Select Step Into or Step Over or Step Out from the Debug menu . 2. Press function key f8 to Step Into, Shift+ f8 to Step Over, or Ctrl+ shift + f8 to Step Out. 3. Click on the Step Into, or Step Over or Step Out button on the Debug toolbar. 50. When stepping through a program a program, how can you tell which statement is about to be executed? Whenever a step is taken the statement to be executed next will be highlighted within the Code Edit Window, with a right- pointing arrow in the lift margin. 51. What is a user-induced error? How do user-induced errors differ from syntactic error and logical errors? User-induced errors are the result of mistakes made by the user when the program is executing. Whereas syntactic errors are made during compilation and logical errors occurs during program execution. 52. What is an error handler? An error handler is a series of VB statements that is intended to recognize an error when it occurs and then provide appropriate corrective action. 53. What is the purpose of On-Error-Go-To statement? On-Error-Go-To statement redirects the program logic to remote statement when an error occurs. 54. What is a label? Within a given statement, how can a label be identified? Label is the first statement in the error trap routine. It provides a target for the continuing flow of program logic. 55. What is the purpose of Resume statement? Resume statement returns the program logic to the statement that originally caused the error. 56. Describe three different forms of Resume statement. What is the purpose of each? Resume statement is written simply as Resume whish returns the program logic to the statement that originally caused the error. You can also write as Resume Next, causes the program logic to be returned to the statement immediately following the one that caused the error. Resume return label causes the program logic to be returned to the remote statement with the specified return label. 57. What is the purpose of On-Error-Go-To O statement? This feature is useful if you want to activate error trapping in one part of a program, and then disable it in another part. 58. What is the purpose of Exit Sub statement? The Exit Sub statement directs the program logic out of the event procedure thus avoiding the error trap. 59. Are resume and exit sub required in all the programs that include an error handler? Explain? The Resume and Exit Sub statements are not always needed within an error handler. Or one may be required, not the other. 60. What are error codes? How can error codes be used within an error handler? Visual Basic associates an integer error code with each type of execution error. Thus, an error handler can process an error code by means of an If-Then-Else or a Select Case statement, and take appropriate corrective action. 61. What are advantages to a stand-alone executable program? What are the disadvantages? Stand-alone program can be run independently of the visual basic development system, and they can easily be transported from one computer to another. On the other hand they cannot be edited, and the interactive debugger is not available in the event of an execution error. 62. Describe the process used to generate a stand-alone executable program from visual basic source files? Simply select Make from the File menu within the VB environment. Then provide the name of the executable file and click the OK button. This will result in a anew file with the given name and extension .exe. 63. How are the name and location of a stand-alone executable program specified? The new file, name.exe, can then be moved out of the visual basic system or moved to a different computer and then executed on its own. VISUAL BASIC QUESTIONS AND ANSWERS

UNIT 4: Procedures: modules & processors- sub processors- event & function processors- scope- optional arguments. Array: characteristics- declaration-processing- passing arrays to processors- dynamic arrays- array related functions- control arrays- looping with for each- next.

1. What is a module in Visual Basic? How do form modules differ from general modules? Large projects are much more manageable if the broken up into modules, each of which contains portions of the code comprising the entire project. A Form module contains declaration, event procedures and various support information for their respective forms and controls. 2. What is the difference between a module and a procedure? A module is a broken up parts of large projects which contains portions of the code comprising the entire project. Whereas a procedure is a self contained group of VB commands that can be accessed from a remote location within a VB program. 3. Name three significant advantages to the use of procedures? The three advantages are: 1. Sub procedures or subroutines. 2. Function procedures 3. Property functions 4. What is the difference between a sub procedure, an event procedure and function procedure? A sub procedure and a function procedure are commonly used in beginning and intermediate level programs. And an event procedure is a special type of sub procedure which accessed by some specific actions. 5. How are sub procedures named? Does a sub procedure name represent a data item? Sub procedure name (arguments) ……………………………………………. Statements …………………….. End Sub The procedure name must follow the same naming conventions used with variables and arguments represent information transferred into the procedure from the calling statement. 6. What is the purpose of arguments? Are arguments required in every procedure? Arguments represent information transferred into the procedure from the calling statement. Each argument is written as a variable declaration; i.e.: Argument name As data type 7. How are arguments written within the first line of a procedure definition? Arguments represent the information that is transferred into the procedure from the calling statement. Each argument is written as a variable declaration, i.e. ; Argument name As data type. The data type can be omitted if the argument is a variant. 8. How are the function procedure named? Does a function procedure name represent a data item? Compare with the rules that apply to the naming of sub procedure? A function name is therefore represents a data item and has a data type associated with it. Within a function definition, the definition name must be assigned the value to be returned as though a function name were an ordinary variable.

9. What is an array? In what ways do array differ from ordinary variables? Many applications require the processing of multiple data items that have common characteristics such as a set etc are named as Array. The data items that make up an array can be any data type as they must be all of the same type. 10. What condition must be satisfied by all elements within a given array? The data items should share the same name and must be all of same data type. 11. How are individual array elements identified? Each individual array elements is referred to specify the array name followed by one or more subscripts, enclosed within a parenthesis. 12. What are subscribed variables? How are they written? The individual elements within an array are called as subscribed variables. A subscribed variable can be accessed by writing the array name, followed by the value of the subscripts enclosed within the parenthesis. It can also be written as a constant, a variable or a numeric expression. 13. What is meant by dimensionality of an array? The number of subscripts is known s dimensionality of an array. 14. Suggest a practical way to visualize the one dimensional and two dimensional? It is helpful to think about one dimensional array as a List and two dimensional array as a Table. 15. When declaring an array what information is provided to the Dim statement? How is the Dim statement written? For declaring an array dim statement is used and within the Dim statement each array name must be followed by one or more integer constants, within an enclosed parenthesis and must be separated by commas. To declare array using Dim statement: Dim array name (subscript 1 upper limit, subscript 2 upper limit, etc)As data type. 16. How are the lower and upper bounds of a subscript specified in a Dim statement? The different lower limits can also be included within a Dim statement and each subscript normally ranges from 0 to specified upper limit. Dim array name(subscript 1 lower limit To subscript 1 upper limit, subscript2 lower limit To subscript 2 upper limit, etc )As data type. 17. How can the subscript range of all arrays be specified to begin at 1 rather than 0? In some applications it is more natural to use arrays whose subscripts begin at 1 rather than 0 thus a more natural selection for many programmers. 18. What value is assigned to all numeric array elements when the array is first declared? What value is assigned to all string array elements? In Visual Basic the elements of a numeric array are initialized to 0 when they are declared. The element of a string array is initialized as empty strings. 19. How can an array be declared whose elements are of user defined data type? The elements of an array may be a user defined data type rather than a standard data type. This is handled in the same manner as ordinary variables. 20. How are individual array elements accessed? The individual array elements within an array can be assigned by writing the array name followed by the value of the subscript enclosed within a parenthesis. 21. Within a user defined array, how are individual members of an array elements accessed? Within an user-defined array, the individual components are accessed by: Array name (subscript). Member name 22. How is an array argument written within the first line of a procedure definition? The arguments in the first line of the procedure definition may be either subscripted variables or ordinary variables depending on the program logic. 23. How is an array passed to a procedure as an argument? The arrays can be passed to procedures as arguments in much the same manner as ordinary variables are passed as arguments. If an argument is an array, however, an empty pair of parenthesis must follow the array name. 24. How is an individual array element passed to a procedure as an argument? Individual array element may also be passed to procedures as arguments which are written in the normal manner when they appear as arguments within a procedure reference. 25. What is a dynamic array? How is it declared? A dynamic array is an array whose size can be changed at various places within a program. To declare a dynamic array, we use the Dim statement, followed by the array name and an empty pair of parenthesis; i.e.; Dim array name () As data type. 26. Once a dynamic array is been declared, how is its size specified? Can a numeric variable or a numeric expression be used for the size specification? Once the dynamic array is declared, to specify the actual size we use Re Dim statement; i.e. ; Re Dim array name (subscript1 upper limit, subscript2 upper limit etc). Here unlike Dim statement , integer variables or expressions may be used to represent the subscript limits. 27. Can lower subscripts limit and upper limits both appear within a dynamic array size specification? In dynamic array elements both lower and upper subscripts limits are been used. 28. When a dynamic array is re dimensioned, what happens to the value previously assigned to the array elements? When a numerical array is re dimensioned, the values previously assigned to the array elements will be reset zero. 29. How can the values previously assigned to the elements of a dynamic array be retained when the array is re dimensioned? The previously assigned value will be retained if the Re Dim statement includes the keyword Preserve; i.e. ; Re Dim Preserve array name(subscript 1 upper limit, subscript 2 upper limit, etc) 30. Summarize the purpose of each of the following array- related functions: Array, Is array, L Bound. U Bound. Array creates a variant type array. The arguments represent array elements. Is array returns a True/False value that is True if the argument is an array and False otherwise. L Bound returns the subscript lower limit of the array argument. U Bound returns the subscript upper limit of the array argument 31. What is a control array? How is it created? Multiple controls of the same type can be grouped into an array, in the same manner as a collection of data items. Such a grouping is known as control array. It is created during design time. 32. Can all of the elements of a control array be assigned the same caption? Can the elements be assigned different captions? All of the control array elements will share the same name but are distinguishable by the value of their index. The captions will also be the same, when the control array is created. 33. How are the individual controls within a control array accessed? The individual element is referred to simply by writing the name followed by appropriate index; i.e. ; control array name (subscript). 34. How can a property of a control array element is accessed? By writing the name followed by appropriate index in parenthesis followed by a period and the property identifier. i.e. ; control array name (subscript) property. 35. How is a new control added to a control array during run time? How is an existing control deleted? A control array can be created by placing a control within the Form Design Window and assigning a value of 0 to its index property. Then copy and paste the control, resulting in a new control with the same name in the upper left corner. You may drag the new control to its desired location within the Form Designer Window. And deleted during run time. 36. When the elements of a control array share the same common event procedure, how is one control distinguished with another within the event procedure? The control array elements share the common event procedure using an index or subscript value to distinguish one control from another. 37. How does a For-Each-Next structure differ from the more commonly used For To-Next structure? What advantages does the For-Each-Next structure offer? For T0-Next structure requires the values to be known explicitly whereas For-Each-Next does not. The advantage is that the value of n is not required within the loop structure and hence need not be known explicitly. 38. Can the For-Each-Next structure be utilized with dynamic arrays? The For-Each-Next structure may be used in dynamic as well as static arrays and for either index must be a variant. 39. What restriction applies to the index within a For-Each- Next structure? For-Each-Next structure should have index as variant. VISUAL BASIC QUESTIONS AND ANSWERS UNIT 5: Data files: characteristics- accessing & saving a file in VB- the common dialogue control- process in a data file- sequential data file- random- access data files- binary files.

1. What is a file? What kind of information can be contained within a file? A file is an orderly self contained collection of information. Any type of information can be stored within a file. 2. What types of components comprise a sequential (text) file? What are the advantages and disadvantages? Sequential file are the easiest to work with, since they can be created by a text editor or a word processor or by a VB program. Such files consist of variable-length strings, organized into individual lines of text. It can be printed or displayed at the operating system level and they are easily imported into application program such as a word processor. This process can be time consuming when searched through a file. 3. What is a record? What is a field? What is the relationship between record and field? A record is a set of related data items such as a name, an address and a telephone number. Each data item within a record fills a field. Any record can be directly accessed by specifying the corresponding record number and location. Thus, it is not necessary to read through the entire file in order to access a particular record. 4. What type of components comprises a random access file? What are advantages and disadvantages? Random access files are organized into fixed-length records. Any record can be accessed directly by specifying the corresponding record number and location. It is not necessary to read through the entire file in order to access a particular record. Applications that require direct access in individual records without regard to their order will therefore execute much faster with direct rather than sequential data files. 5. What types of component comprise the binary file? What are the advantages and disadvantages? Binary file stores information as a continuous sequence of bytes. Such files appear un intelligible when printed or displayed on a computer screen, but their contents can be read into or written out of a computer faster than other file types, particularly sequential files. 6. Summarize the method to add the common dialog control to the another. To add common dialog control, first select Components from the Project menu. Then click on the Control tab and check the box labeled Microsoft Common Dialog Control. Once it is activated, the common dialog control will appear on the lower right portion of the Toolbox. 7. What is the purpose of each of the following common dialog control methods: filter, Show open, Show Save, and show print? To access an existing file i.e. to open a file , simply add a statement CommonDialog1. Show Open The type of files i.e. the extension can be specified within a program by assigning a string to the CommonDialog1. Filter property. To save a file with the specified name adds a statement Common Dialog1.Show Save. The common dialog control also permits the display of dialog boxes that allow the user to specify the printer settings, to select a font, or a color using Common Dialog1. Show Print. 8. Describe in general terms the three principle steps involved in processing the information within a data file? All application involving the use of data file are carried out in three steps: 1. Open the data file. 2. Process the file, as required by the application. 3. Close the file. 9. What happens when a data file is opened and closed? Opening the data file associates a channel number with a specified named data file. It also specifies certain information about the data file such as mode, the access type. Closing a data file is a formality that simply deactivates the condition that are specified when a file was opened. VB automatically closes all data file at the end of the program. 10. Describe each of the file-related terms: channel number, mode, access type restrictions. Channel number also known as file number. Mode is input, output, append, random, or binary. Access type includes Read, Write or Read Write and restrictions are Shared, Lock Read, Lock Write, or Lock Read Write. 11. What modes can be selected when opening a sequential file? The modes are Input, Output, Append, Random or Binary are been selected when opening a sequential file. 12. How numeric constants stored within a sequential data file? The text is organized into individual lines, with each line ending with ASCII line feed and carriage return characters. Each line of text can contain both numeric constants and strings, in any combination. 13. How are consecutive numeric constants separated within the same line of a sequential data file? Within any line, consecutive numeric constants can be separated by commas. 14. Under what condition must a string be enclosed in quotation marks within a sequential data file? If a string includes commas or blank spaces as a part of the string, it must be enclosed in quotation mark. 15. Are separator required for consecutive strings within the same line of a sequential data file? Consecutive strings that are enclosed in quotation marks need not be separated by commas. 16. Within a sequential data file what is the difference between the Input # statement and the line input # statement? When it is used? Data files are usually read from the sequential data file via the Input # statement which is written as Input #n, data items, where n refers to channel number. 17. What is the purpose of input library function? How does it differ from the input # statement? The input library function returns the specified number of bytes from a given data channel written as Input (number of bytes, #n). When combined with library function the Input function can be used to read an entire text file as a single data item. 18. Within a sequential data file what is the difference between the Print # statement and Write # statement? The data items are usually written to a sequential data file via Print # statement which in general terms written as Print #n, data items. And when writing data to a text file we use Write # statement because it is useful when generating a text file from information entered from the keyboard and written as Write #n, data items 19. What is the purpose of EOF and LOF function? What does the function return? The LOF function is to determine the file size and returns the assigned values. The EOF function is used to detect the end- of-file condition 20. How is the new information appended to an existing sequential data file? A program that creates a new file can easily be altered so that it also appends additional information to an existing text file. To do so, simply open an existing text file as an Append file; then proceed as you would create a new text file. 21. How is a particular record in random access data file identified? How can a particular record be accessed? Random access data files consist of collection of fixed-length records, each of which are assigned a unique record number and are accessed by referencing the record number. 22. How is the composition of the records within a random access data file defined? Information can then be read from the record or written to the record as required by the individual application. With random access files, the Open statement takes on the form Open filename For Random As #n Len= record length. , since Random is the default file type, in the absence of an explicit specification. 23. What is the purpose of Len function? What does this function return? Len function is used to write record length as an integer, constant or expression. It returns the length in bytes of a previously defined data item. 24. How is a Get # And Put # statement used with a random access data file? How is the statement interpreted if the record is not explicitly shown? Data items are read from the random access data file, one record at a time via Get # statement generally written as Get #n, record number, data item. Data items are written to the random access data file , one record at a time, via Put # statement generally written as Put #n, record number, data item. If the record is not explicitly shown, it s taken to be that of the record following the last Get # or the last Put # statement. 25. What is meant by a pointer? How can the location of a pointer be determined? How can a pointer be repositioned? A pointer is used to indicate the location of any particular record. The pointer must be positioned properly before a record can be read from or written to a direct data file. The pointer location is determined by assigning values to the variable Record Number.

Recommended publications