< strong>Code to calculate average
'function to calculate avarage
Function CalcAverage(ByVal ParamArray val() As Integer) As Double
Dim sum As Double = 0
For i As Integer = LBound(val) To UBound(val)
sum += val(i)
Next
Dim length As Double = val.Length
Dim average As Double = sum / length
Return average
Return sum
End Function
Calling the method
Private Sub btnSum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'output :3
MessageBox.Show(CalcAverage(1, 2, 3, 4, 5))
'output :6.333333
MessageBox.Show(CalcAverage(4, 5, 10))
End Sub