Site hosted by Angelfire.com: Build your free website today!


 

Name:

Date:

Quiz Two / Visual Basic II

Instructions: For each example below, state the goal of the subroutine or function (e.g. what task does it accomplish?).  Explain how it accomplishes the goal.

Example One

 

    Private Sub MysterySub1(ByRef strLeft As String, ByRef strRight As String)
        'Explain what this subroutine does.  What goal does it accomplish
        'and how does it do it?
        '
        '
        '
        '
        '
        '
        '
        '
        '
        '
        '
        '
        Dim strSomePlace As String

        strSomePlace = strLeft
        strLeft = strRight
        strRight = strSomePlace
    End Sub

 

Example Two

 

    Private Function MysteryFunction1(ByRef strValues() As String) As String
        'Explain what this function does.  What goal does it accomplish
        'and how does it do it?
        '
        '
        '
        '
        '
        '
        '
        '
        '
        '
        '
        '
        Dim intIndex As Integer
        Dim intElements As Integer = strValues.Length
        Dim strSomething As String

        If intElements > 0 Then
            strSomething = strValues(0)
            intIndex = 1
            Do While intIndex < intElements
                If CInt(strValues(intIndex)) < CInt(strSomething) Then
                    strSomething = strValues(intIndex)
                End If
                intIndex = intIndex + 1
            Loop
            Return strSomething
        Else
            Return ""
        End If
    End Function

 

Example Three

 

    Private Sub MysterySub2(ByRef strArray() As String)
        'Explain what this subroutine does.  What goal does it accomplish
        'and how does it do it?
        '
        '
        '
        '
        '
        '
        '
        '
        '
        '
        '
        '
        Dim intLength As Integer
        Dim intMiddleIndex As Integer
        Dim intIndex As Integer

        intLength = strArray.Length

        If (intLength <= 0) Then
            Return
        End If

        intMiddleIndex = intLength / 2

        For intIndex = 0 To intMiddleIndex - 1
            MysterySub1(strArray(intIndex), strArray(intLength - 1 - intIndex))
        Next
    End Sub