Sie sind auf Seite 1von 5

WOMEN’S UNIVERSITY IN AFRICA

Addressing gender disparity and fostering equity in University Education

FACULTY OF MANAGEMENT AND ENTREPRENEURIAL DEVELOPMENT


STUDIES & INFORMATION TECHNOLOGY

______________________________________________________________________________

BSc HONOURS DEGREE IN INFORMATION SYSTEMS

MAIN PAPER

IS122: VISUAL BASIC.NET

INTAKE 10: FIRST YEAR SECOND SEMESTER

DATE: WEDNESDAY 14 NOVEMBER 2012

TIME: 3 HOURS AFTERNOON

INSTRUCTIONS

Answer Section A and any three from Section B.

1
SECTION A

Question 1

Find errors and correct them:

a) Dim array As Integer() = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}


Dim total As Integer = 0

For i = 0 To array.GetUpperBound()
total += array(i)
Next

mgsbox("Total of array elements: " & total) [5]

b) Public Class frmInterest

Private Sub frmInterest _Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

Dim Interest, AmtInvested As Decimal


Dim RateOfInterest As Short
Dim Year As Integer

Interest=CalculateInterest(AmtInvested, RateOfInterest, Year)

Public Function CalculateInterest(ByVal Principal As Decimal, ByVal_


InterestRate As Decimal,ByRef NumberOfYears As Integer)
Dim interest as decimal
Dim Year as integer

Interest = 0
For Year =1 to NumberOfYears
Interest = Interest+((Principal + Interest))+ InterestRate/100)
Next Year

End Sub
End Class [7]

c) Dim int rate = 1.5


Dim double price = 0.0

2
if(rate >= 0.0 and rate < 1.0)
price = 20 * rate
else (rate <= 1.0 and rate < 2.0)
price = 15 * rate
else (rate >= 2.0)
price = 10 * rate

msgbox(price) [5]

d) Sub Fibonacci(S1 as NUMBER,S2 as INTEGER,N as INTEGER)

lstDisplay.add.items(S1,S2)
Dim count as Integer,dim term as Integer

For count EQUAL 3 TO N


Term = S1+S2
msgbox(term)
S1=S2
S2=term
Next value
End sub [5]

Question 2

Give output for following sections of code.

a) Dim String1 as string


Dim String2 as string
String1=”VB IS NOT AN OOP”
String2=”an”
S = Instr(3,String1,String2)
Msgbox(S)
[10]

b) Sub first()
Dim x as integer
x=20
Display.items.add(x)
Call second(x)
Display.items.add(x)
End Sub

3
Sub second (y as integer)
y=40
Display.items.add(y)
End Sub

Private Sub Command1_click()


Call first
End Sub [8]

SECTION B

Question 3

a) Write a sub program to find the largest, smallest, sum and average number of array of ten
numbers. [12]
b) Write a VB procedure to reverse the digits of given number e.g. 1234 => 4321. [8]

Question 4

a) Assume you want to generate a multiplication table of any given number from 1 to 12.
Write a program that allows the user to enter the number and then generate the
multiplication table. The output a number 2 should look like this:

1X3=3
2x3=6
.
.
12 x 3=26 [12]

b) Explain the following properties:


a) MaxLength property of Text Box
b) Value property of Option Button
c) ListCount property of List Box
d) List property of Combo Box [8]

4
Question 5

a) Explain any five numeric functions in VB [5]


b) Errors in VB can be classified as logic, runtime and design. Using typical examples
differentiate one from another [10]
c) Using relevant example, differentiate a sub procedure from a functional procedure. [5]

Question 6

A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges
an additional $0.50 per hour for each hour or part thereof in excess of three hours. The
maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer
than 24 hours at a time.

Required :

Write a program that calculates and displays the parking charges for each customer who parked a
car in this garage yesterday. You should enter in a TextBox the hours parked for each customer.
The program should display the charge for the current customer. The program should use the
method Calculate Charges to determine the charge for each customer. [20]

[END]

Das könnte Ihnen auch gefallen