You are on page 1of 2

Question 6: (10 marks, 15 minutes)

Consider the following code segment:

Sub Question1VBA()

Dim i As Double, j As Double

Const numrows = 4

For i = 1 To numrows
For j = 1 To (2 * i - 1)
Range("A1").Offset(i, numrows + 1 - i + j).Value = "*"
Next
Next

End Sub

a) Reproduce the following grid in your answer book and fill in the output of the
above subroutine:

  A B C D E F G H I J
1                    
2                    
3                    
4                    
5                    
6                    
7                    
8                    
9                    
10                    
[8]

b) What is the difference between a variable of type variant and a variable of type
string ?

[2]
Question 7: (8 marks, 13 minutes)

Consider the above function DoCalc:

Function DoCalc(thenumber As Double)

Dim WSF As WorksheetFunction


Set WSF = WorksheetFunction

Const themean = 0.2


Const thestddev = 0.1

Dim x As Double

If (thenumber > 0) And (thenumber < 1) Then


x = WSF.NormInv(thenumber, themean, thestddev)

Else
If thenumber <= 0 Then
x=0
End If

If thenumber >= 1 Then


x=1
End If
End If

DoCalc = x

End Function
a) What is the difference between a Boolean and a Double variable type? [2]
b) What does the function DoCalc return if thenumber = 0.5? [4]
c) What does the function DoCalc return if thenumber = 0? [2]

You might also like