You are on page 1of 9

Q1. Define array with syntax and example.

An array is a collection of values of the same data type. The values in an array are called array elements. Array elements are accessed using a single name and an index number representing the position of the element within the array. Arrays are used in a database application to handle data for processing. Declaring Arrays Unlike simple variables, arrays must be declared with the Dim (or Public, or Private) statement followed by the name of the array and the index of the last element in the array in parentheses for example: Dim Ages(19) As Integer Dim Names(19) As String

Q2. What is Select Case? Write its syntax.
Select Case is preferred when there exist many different conditions because using If...Then..ElseIf statements might become too messy. The format of the Select Case control structure is show below: Select Case expression Case value1 Block of one or more VB statements Case value2 Block of one or more VB Statements Case value3 . . Case Else Block of one or more VB Statements End Select

In Visual Basic.Q3.768 to 32. which can be computed mathematically with various standard operators such as add.5807 +/79.477. -922. monthly bills. share values.685.648 to 2.94065645841247E-324 for negative values 4.337.337. depending on the range of values they can store.203. price of goods. fees and others.767 -2.94065645841247E-324 to 1.147. minus.483.402823E+38 for positive values.147.483. Explain all data types in VB. the number of students in a class. height.648 -3.402823E+38 to -1.79769313486232e+308 to 4.514.9228162514264337593543950335 (28 decimal places).337.401298E-45 to 3. -1.543.335 if no decimal is use +/.203. multiply.7.162.593. Examples of numeric data types are examination marks.950. .401298E-45 for negative values 1. numeric data are divided into 7 types. weight.228.79769313486232e+308 for positive values. Visual Basic classifies the data types in two major categories:1) Numeric Data Types 2) Non-Numeric data types 1.5808 to 922. divide and more. Numeric Data Types Numeric data types are types of data that consist of numbers.685. Type Byte Integer Long Single Storage 1 byte 2 bytes 4 bytes 4 bytes Double 8 bytes Currency Decimal 8 bytes 12 bytes Range of Values 0 to 255 -32.264.477.

9999 True or False Any embedded object Any value as large as Double Same as variable-length string Q4. specified by the indicator’s position Q5. i. What is Scrollbar? Explain the properties and methods The scroll bar control is a long stripe with an indicator that lets the user select a value between the two ends of the control. Max. therefore.2. and Value. Implement the program to generate the Fibonacci series Private Sub Command1_Click() Dim a.    Min : The control’s minimum value Max: The control’s maximum value Value: The control’s current value. The ScrollBar control comes in two versions: horizontal and vertical. The basic properties of the scrollbar control. The non-numeric data comprises text or string data types. Non-numeric Data Types Nonnumeric data types are data that cannot be manipulated mathematically using standard arithmetic operators. Object data type and Variant data type . b. Data Type String(fixed length) String(variable length) Date Boolean Object Variant(numeric) Variant(text) Storage Length of string Length + 10 bytes 8 bytes 2 bytes 4 bytes 16 bytes Length+22 bytes Range 1 to 65. the Boolean data types that store only two values (true or false). the Date data types. 100 to December 31. sum As Integer c = 20 a=0 y=1 Print a . c. Other than their orientation. there are no difference between the two versions.400 characters 0 to 2 billion characters January 1. are properly named Min.

Print y For i = 3 To c sum = a + y Print sum a=y y = sum Next i End Sub Q6.Text=counter counter =counter+1 Loop * The above example will keep on adding until counter >1000. The above example can be rewritten as Do num. Do Loop The formats are a) Do While condition Block of one or more VB statements Loop b) Do Block of one or more VB statements Loop While condition c) Do Until condition Block of one or more VB statements Loop d) Do Block of one or more VB statements Loop Until condition Example: Do while counter <=1000 num.Text=counter counter=counter+1 . Explain all looping statements in VB with simple example.

The sequence of these events determines the sequence in which the code executes .Text=counter Next Q7. the code doesn’t follow a predetermined path rather it executes different code sections in response to events . or even from the application itself.always theprogrammers first program . thus the path through the application’s code or the sequence of execution differs each time the program runs.. In an event –driven application . 3) OLE programming is simple. This aids your programming skills allowingyou to concentrate on developing novel ideas instead of going over oldground... Advantages 1) It is not just a language to program in but a whole graphicaldevelopment environment. 2) It is quick to develop new programs.Next Loop The format is: For counter=startNumber to endNumber (Step increment) One or more VB statements Next Example: For counter=1 to 10 display. . A newcomer will have a windowproudly opening and greeting you with "Hello World!" .in less than 5 minutes. Events can be triggered by the user’s actions . What do you mean by Event driven programming? Discuss the advantages and disadvantages of Visual Programming.Loop until counter>1000 messages from the system or other applications. This allows you to embed objects suchas Word documents and Excel spreadsheets with a minimum of fuss.

this could also be seen as a disadvantagewhen a bug arises! 10) Perhaps its strongest advantage is its simplicity. 9) The programs a programmer produces in VB are not portable andcannot be used on non-Windows systems. thisis largely due to the additional code that is often included that isnot really necessary for your program to run. 4) Because of its age VB does not allow many modern techniques such asObject Orientated Programming. Becauseof its age little is being down to further the VB environment and ithas been largely superceded by VB. 5) It is widely used for in-house application program development andfor prototyping. 5) As you can control the checking and warning systems in VB it oftenenables the programmer to write code that is very difficult to troubleshoot when a bug arises.e) Because of its over-simplified approach VB can produce programmersthat are sloppy in their work leading to workarounds having to beemployed. 3) VB is an interpreted language which again slows the execution ofyour program down.d) VB programs require large libraries to be present on your PC toenable them to work. 9) Strict programming structures can be "turned off" to allow you toquickly develop a program .Object Orientated Programming .net). These COM programs can be written in any language. 8) Because of its popularity there are many resources available to theuser . 11) VB is a "component integration language" which utilises Microsoft'sComponent Object Model ("COM") that allows parts to be bolted ontoprograms easily.4) It can be used as a front end to SQL (or other databases) allowingthe user to enhance the way they access their data. 2) Programs that are written in it tend not to be the missing from VB. If you do not have them the programmer eitherhas to supply them or you have to download them. . Watch a programmers facewhen you talk to them about "GoSub" and "On Error" commands! 7) OOP . 6) It can also be used to create ActiveX and COM components for useonline or in desktop applications.m) Service Packs! Everyone knows about Microsoft's love of servicepacks to fix the many bugs that have accumulated over time. As the name Basic suggests it useseasy to understand and remember and other languages (even byMicrosoft!). Disadvantages 1) It is not suited to complex modern programming 8) There is no threading support (although this is also available inVB. 10) Mathematical performance is poor which slows down the speed of yourprogram. this isone of the most common techniques in all new languages allowing codeto be easily reused (although this is available in VB.websites are numerous and books are plentiful for theprogrammer needing help. 6) VB consists of features and syntax borrowed from other languages(often ones that are now no longer used). 7) It is very simple to learn. There is hardlyany learning curve for programmers to begin learning the language orcoming from another language.

Events are methods that can be called in special ways—usually by the user interacting with something on a form or by Windows itself—rather than being called from a statement in your code. These actions. Suppose that you have an object. To illustrate this point. most objects have methods. Method and Event. Methods are actions the object can perform. Visual Basic Controls Alignment : The commands on this menu align the edges or middles of selected controls: Lefts.Rights align the left. and right sides of thr selected controls. Method In addition to properties. different dogs have different values for these properties. Indeed. include barking. in a sense. which describe the object. This Dog object has certain properties common to all dogs. Property All objects have attributes that are used to specify and return the state of the object. the Visual Basic 2010 documentation often calls events methods (something that no doubt confuses new programmers). tail wagging. and the object is a dog. and you’ve already used some of them in previous hours in the Properties window. is really a special kind of method used by an object to signal state changes that might be useful to clients (code using the object). – Alignment. called methods in Visual Basic. however.e. ToolTipText and Visible ). every object exposes a specific set of properties. Name. Explain the term Property. Enabled. These properties include attributes such as the dog’s name.Q8. Figure 3. but not every object exposes the same set of properties. center. the color of its hair. and chewing carpet (don’t ask). All dogs have these same properties. these commands are meaningful only if controls are stacked in a column . In fact. I’ll continue with the hypothetical pet object.Centers. Discuss some common properties for several Visual Basic controls (i. and even the number of legs it has. Caption. A Dog object has a certain set of actions it can perform. in contrast to attributes. Event An event.1 illustrates such a Dog object and its properties. think about the pet object example one more time. To understand this distinction. These attributes are properties.

this property’s value is True. the caption of a Command button control. Every time it’s clicked. CheckBox: The checkbox control presents one or more choices that the user can select. and it is 0 if the CheckBox is cleared. which means that the control can get the focus. it changes status . Visible: Set this property to False to make a control invisible. and False otherwise. The CheckBox control’s main property is Value. Checkbox and Option button. Label. A disabled control appears gray and can’t ac cept user input. Set it to false to disable the control. and its most important property is the text property. through which you can access the control’s properties and methods. Label: This control displays text on a Form that the user can’t edit. Explain the following properties of Textbox control Locked b)MaxLength b) MultiLine c) PasswordChar d) ScrollBars e) Text. you use invisible controls to store information that is used internally by the application and should not be seen or manipulated by the user Name: This property sets the name of the control. You set the label’s text with the caption property. it changes status. so the text appears to be placed directly on the Form. The Option button’s main property is Checked. The Option button is a toggle. Q9. Labels commonly identify other controls and can be transparent. Textbox. and bottom sides of the controls. which can set the text on the control or read the text that the user enters. for example. TEXTBOX CONTROL . and the strigs displayed next to the checkbox and option button controls Enabled: By default. Textbox: This control displays text that the user can edit.e. and 1 if the CheckBox is checked. and it is True if the control is checked. Sometimes. these commands are meaningful only if controls are placed to each other To grid aligns the controls to the nearest grid point Caption: This property sets the text that is displayed on many controls that don’t accept input .Middles. middle. Every time it’s clicked. The CheckBox is a toggle.Bottoms aligns the top.Tops. Discuss the following elements of user interface i. the text on a label control. Option Button : Option button appears in groups and the user can choose only one of them. The Textbox control is a mini text editor.

and Command Controls. Multi-line textboxes can have a horizontal or a vertical scroll bar or both. Single line textboxes can have a horizontal scroll bar so that the user can view any part of a long line of text. .MaxLength property determines the number of characters that can be entered into a TextBox control If you attempt to insert text programmatically. set the Multiline property to True. By default. the text will be truncated at the length specified by the MaxLength property. Scroll bars will appear in multi-line textboxes even if they aren’t needed or the text doesn’t exceed the dimensions of the control. WAP that will perform the following operations by using Form. To change this behavior. Label. ScrollBars: This property controls the attachment of scroll bars to the TextBox control if the text exceeds the control’s dimensions. Textbox. the control holds a single line of text. PasswordChar property is of type String Multiline : This property determines whether the TextBox control will hold a single line or multiple lines of text. Q10.