' Saved as ParamArray_Console_Demo.vb.txt Module ParamArray_Console_Demo Sub Main() show(StudentScores("Anne", "10", "10", "10", "11")) show(StudentScores("Mary", "High", "Low", "Average", "High")) Dim JohnScores() As String = {"35", "Absent", "40", "30"} show(StudentScores("John", JohnScores)) End Sub Function StudentScores(ByVal name As String, _ ByVal ParamArray scores() As String) As String ' Statements for Sub procedure Dim strResults As String Dim Score As String Dim decSum, decAverage As Decimal Dim intCount As Integer = 0 For Each Score In scores ' Iterate through array If IsNumeric(Score) Then ' check to see if array element is a number intCount += 1 ' If it is 'count' add it to the Sum decSum += CType(Score, Decimal) End If Next If intCount > 0 Then ' Check to see if there were any grades counted decAverage = decSum / intCount strResults = name & " has an average grade of: [" & _ decAverage.ToString("#.00") & "]" Else strResults = name & " has no recorded grades." End If Return strResults End Function Sub show(ByVal str As String) Console.WriteLine() Console.WriteLine("--------------------------") Console.WriteLine() Console.WriteLine(str) Console.WriteLine() Console.Write("Press enter to continue...") Console.Read() End Sub End Module