Hi, I am trying to create a program that the user enters the number of enrollments for 5 different campuses during two semesters. I just got started and here is what I have so far but when I run the program it is stuck in an infinite loop and will not go to the next function. I am not sure how to end the loop. THANKS for any help! :) Here is what I have so far:

Module Module1
    Dim SIZE As Integer = 5
    Dim campus() As String = {"Decatur Day", "Decatur Evening", "Huntsville Day", "Huntsville Evening", "Distance Learning"}
    Dim semester() As String = {"Fall 2010 semester", "Spring 2011 semester"}
    Const ROWS As Integer = 2
    Const COLUMNS As Integer = 5
    Sub Main()
        Console.WriteLine("Please enter the number of enrolled students at Calhoun.")
        Console.WriteLine(" ")

        Dim tempArray2() As Integer = New Integer(SIZE) {}
        Dim row, column As Integer
        Dim total() As Integer = New Integer(SIZE) {}
        Dim tempArray3() As Integer = New Integer(SIZE) {}
        FillArray(row, column, tempArray2)
        total = GetTotal(total, tempArray3)
    End Sub
    Function FillArray(ByVal row As Integer, ByVal column As Integer, ByVal tempArray2() As Integer) As Integer()
        Dim tempArray(2, 5) As Integer

        For row = 0 To ROWS - 1
            For column = 0 To COLUMNS - 1
                For rowCount = 0 To 1
                    For columnCount = 0 To 4
                        Console.WriteLine("Enrollment for " + campus(columnCount) + " for the " + semester(rowCount) + ":")
                        tempArray(row, column) = CInt(Console.ReadLine())
                    Next
                Next
            Next
        Next
        Return tempArray2
    End Function
    Function GetTotal(ByVal total() As Integer, ByVal tempArray3() As Integer) As Integer()
        Dim tempArray(2, 5)
        For row = 0 To ROWS - 1
            For column = 0 To COLUMNS - 1
                For columnCount = 0 To 4
                    Console.WriteLine("The total enrollment for  " + campus(columnCount) + " is: ")
                    Console.WriteLine(total)
                    total = tempArray(2, 5)
                Next
            Next
        Next

        Return tempArray3
    End Function

End Module

Actually is not an infinite loop. It will run for 100 times, when you need only 10.

You can simplify the for-next using:

For row = 0 To ROWS - 1
            For column = 0 To COLUMNS - 1
                        Console.WriteLine("Enrollment for " + campus(column) + " for the " + semester(row) + ":")
                        tempArray(row, column) = CInt(Console.ReadLine())
            Next
        Next

In the GetTotal function you may siplify it using:

For column = 0 To COLUMNS - 1
                Dim total = 0
                For row = 0 To ROWS - 1

                    total += tempArray(row, column)
                Next
                    Console.WriteLine("The total enrollment for  " + campus(column) + " is: ")
                    Console.WriteLine(total)
            Next

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.