=========================preview======================
(ISOM3230)[2011](f)midterm~=0_rzkjdm^_11238.pdf
Back to ISOM3230 Login to download
======================================================
5... .

... 3..
.

.
.

.
where x, m and n are three input parameters of a formula.
Part A You are asked to convert the formula into a function called Abc. The function will be called by the subroutine Q1().
Public Sub Q1() Dim arr(-3 To 10) As Long Dim i As Long
For i = LBound(arr) To UBound(arr)
arr(i) = i * 2
Next

MsgBox Abc(arr, 2, 8) ' where m = 2, n = 8 End Sub
Answer: (10%)
(Complete the function below. Must use either ByRefor ByValfor each of input arguments.)

Public Function Abc(ByRef x() As Long, _ ByVal m As Long, _ ByVal n As Long) As Double
Dim i As Long
Abc = 0 For i = m To n Abc = Abc + ((5 * x(i)) / (3 + x(i) ^ 2)) Next
End Function
Part B
You are asked to write a wrapper subroutine that transfers data from Column A to an array with the following criteria.
(a)
An empty cell is used to indicate the end of a data set in Column A.

(b)
The array contains values greater than 49 so any data less than or equal to 49 will not be transferred.

(c)
The Abc() function will be used in the wrapper subroutine.


Answer the question by completing the following subroutine.
Line00: Public Sub Q1_Wrapper()
Line01: Dim arr() As Long
Line02: Dim r As Range
Line03: Dim k As Long
Line04:
Line05: [A1].Select
Line06: Do Until IsEmpty(ActiveCell)
Line07: ActiveCell.Offset(1, 0).Select
Line08: Loop
Line09: Range([A1], ActiveCell.Offset(-1, 0)).Select
Line10:
Line11: ReDim arr(0 To Selection.count - 1)
Line12: k = 0
Line13: For Each r In Selection
Line14: If r > 49 Then
Line15: arr(k) = r
Line16: k = k + 1
Line17: End If
Line18: Next
Line19:
Line20: MsgBox Abc(arr, 0, k - 1)

Line21: End Sub
Part C
The overall performance of the wrapper subroutine is not good because it determines an empty data cell one by one using ActiveCelland the Selectmethod. In this part, you are asked to rewrite Line05to Line09 so that ActiveCelland IsEmpty()are not used. (Hints: Using Selection only and no loops are required)
Answer the question by completing the following statements.
[A1].SelectRange(Selection, Selection.End(xlDown)).Select
2 Given thhe following screen shotss

and the following suubroutine,
Publiic Sub BinnaryLikeSe earch(ByReff arr_in()) As Strinng, _ByReff arr_out(() As Striing, _ByVall prefix_ttext As Sttring)
' arrr_in storees all commmon words
' arrr_out storres the re esult wordsds
' preefix_text is the prrefix searcch key
The acttual imple ementation is hiddenn.

End SSub
you are asked to wr ite a complette program tthat will lookk for similar wwords in Coluumn A. The uuser is only requiredd to input th e prefix searrch key in thee Cell C2. Theen the prograam will find aall similar woords in colummn A and outtput those fo und words inn Column E, the immediaate window and a messaage box. In adddition, yourr programm must speci fy valid inputt arguments to call the BiinaryLikeSSearchsu