You are on page 1of 4

Q51. How does the load statement differ from the show statement.

Both are form methods. To open a form and make it visible, show method is used . When we want to assign properties to a form and not shown on screen load method is used. In load method, the form is loaded in memory but not shown on the screen. Syntax of Show method is: Formname.Show style, ownerform Syntax of Load method is: Load<Formname>

Q52. What is control array? What are its utilities? A control array is a group of controls that share the same name type and the same event procedures. Adding controls with control arrays uses fewer resources than adding multiple control of same type at design time. Control array can be created at the following time • • Design time Run time

Control arrays are one of the most interesting features of the Visual Basic environment, and they add a lot of flexibility to the programs: • • • Controls that belong to the same control array share the same set of event procedures; this often dramatically reduces the amount of code to be written to respond to a user's actions. We can dynamically add new elements to a control array at run time; in other words, we can effectively create new controls that didn't exist at design time. Elements of control arrays consume fewer resources than regular controls and tend to produce smaller executables. Besides, Visual Basic forms can host up to 256 different control names, but a control array counts as one against this number. In other words, control arrays let you effectively overcome this limit.

Q53. What do you mean by arrays of array? An array of which each element is itself an array is called an array of arrays, or a jagged array. Having arrays as elements is not the same thing as a multidimensional array, which has more than one index on a single array. Declaration of a jagged array:- Dim jaggedArray(D1)() As datatype For example, you might have an array of months, each element of which is an array of days. Since different months have different numbers of days, the elements do not form a rectangular twodimensional array. In such a case, you can use a jagged array instead of a multidimensional array.

Q54. What is a multi-dimesional array ? Ans. You may need to use two subscripts to identify tabular data, where data are arranged in rows and columns. To define a two-dimentional array or table, the Dim statement specfies the number of rows and columns in the array. The row is horizontal and the column is vertical. Syntax: Dim ArrayName ( [ LowerLimit To ] UpperLimit, [ LowerLimit To ] UpperLimit ) As Datatype Example: Dim strName ( 2, 3 ) As String

What is dynamic array? How to allocate space for dynamic array? How to preserve information in a dynamic array? An array which can be resized or re-dimensioned at runtime is known as dynamic array. 0 To 3 ) As string Q55.Dim strName ( 0 To 2 . Professional applications use splash screens to tell the user that the program is loading and starting. The following statement removes the selected item from the list control but only if an item is selected. E. In order to preserve the data in an existing array the “preserve” keyword is used when there is a need to change the last dimension. List1. “Redim” statement can only appears within a procedure because it is an executable statement which makes the application carries out an action only at runtime.remove item. This initial form is called splash screen. If multiple items are selected list index is the index of the most recently selected items. to zero for numeric type .removeitem list1. VB reset the values to empty for variant type. What is a purpose of splash screen? Ans: Perhaps you have noticed the logo or window that often appears while program is loading.29) End Sub The ReDim statement shown here allocates a matrix of 20 by 30 integers (at a total size of 600 elements).listindx>=0 then List1.Y) Preserving the content of dynamic array:Each time executing the “ReDim” statement al values currently stored in the array are lost. listindex after the removal of the item.g Dim x () as integer Redim x (5) as integer For example the dynamic array matrix one is created by first declaring it at the module level: Dim Matrix 1 () As Integer A procedure then allocates space for the array: Sub CalcValuesNow () ReDim Matrix (19.list1. List box & combo box controls supports this property. It can make a large application appear to load and run faster. ‘0’ length for string type and nothing for object type. It can be declared by the “dim” keyword with empty parenthesis & re-dimensioned by the “redim” statement. List index property:= This is the index of the selected item in the list. the indices of the following item are adjusted accordingly. ReDim preserve x ( + 1) as integer by this declaration the array size is increased by one but all the current information remains intact.listindex End if Q56. Alternatively. since something appears on the . Eg: ReDim preserve x(10) as Integer. the bounds of a dynamic array can be set using variables: ReDim Matrix1(X. We use this property to access specific almosts in the list or delete specific items. For list box control(to remove a selected item) If list1.

d. How many types of procedures are there in Visual Basic? . X as single. Advantage:1) Allow us to break an application into discrete logical units. c. we can display a content menu with the cut. The statements that make up a function are placed within function/ End function. 3) Procedures are reusable across programs with little or no modification. We can reuse the code written in a procedure. What is procedure? A procedure is a set of one or more program statements that can be executed by referring to the procedure name. Q60. You can create your own splash screen or use the splash screen template included woth Visual Basic. Subroutines (a type of procedure) perform a task and don’t report anything to the calling program. c. then modify the form as you need. copy and paste submenus. For Ex: if we have an edit menu named mnuedit with cut. A function is similar to a subroutine. b. Function Next Day() As Date Next Day = Date() + 1 End Function. We can reuse the code written in a procedure as it can be executed any number of times by making a call to the procedure. but a function returns a result. code private Sub mnuCut_click() MsgBox “you selected cut” End Sub private Sub mnuCopy_click() MsgBox “you selected copy” End Sub private Sub mnuPaste_click() MsgBox “you selected paste” End Sub Private Sub Form_MouseDown( Button as Integer. thus making the application more readable. In the add form dialog box. A procedure is a set of one or more program statements that can be executed by referring to the procedure name. Y as Single) If button = Vb Right button then Pop-up Menu mnuEdit End if End sub Q58. b. Q57. Shift as Integer. 2) Procedures help in debugging an application because debugging separate units of an application is easier them debugging the application as a whole. and paste commands by calling pop-up Menu mnuedit. Distinguish between procedure and function? Procedure: a. e. Sub Show Date() Msg Box Date() End Sub e. To call a function: Dim d as Date d= Next Day() Q59. choose the Splash screen to add a new form. copy. To call a procedure: Show Date() Function: a.screen while the rest of the application loads. How can we create a pop-up menu? In visual basic we can display a context menu by calling the pop-up menu method and passing it any top level menu object. d. The state means that make up a procedure and placed within sub /End sub. Functions commonly carried out calculation and report the result. as it can be executed any number of times by making a call to the procedure.

Example: If a user click a command button object with the name command1. Properties are type of variables that store the values for an object of a class or a structure. returns a value to the calling code. c) Property procedure: A property procedure is a set of code statements that are used to assign or creative the value of the properties declared with in a module. If we need a procedure to returns a value so that the return value can be further procedure in the calling code. End function statements a function procedure unlike a sub procedure. we can write the code in a procedure and call the procedure from anywhere within the application. If we need to perform as specific task posted of writing the code multiples times in different parts of the application. It is a declared as public then other application can use it. Event handling procedure : An Event handling procedure is a block of code that is executed when a specific event occurs. . such as the click of button the loading of a form in the memory or fulfillment of a user defined condition. we should create a function procedure instead a sub procedure. a class or a structure.a) Sub procedure: Sub procedure has two types:-(i) General procedure : A general procedure is a block of code that performs a specific task. (ii) b) Function procedure: A function procedure is a block of code enclosed within the function. the procedure named command1_click() is called and the code within the procedure is execute.