Function Param배열_활용(ByVal coco As Boolean, ByVal ParamArray arg() As Integer) As Object
Dim l합계 As Long
Dim s평균 As Single
' UBound 이용하여 배열의 상위경계 값을 참조 !!
For i As Integer = 0 To UBound(arg, 1)
Debug.WriteLine("Score " & i & ": " & arg(i))
Console.WriteLine("Score {0} {1} ", i, arg(i))
l합계 = l합계 + arg(i)
Next i
s평균 = l합계 / (UBound(arg, 1) + 1)
If coco Then
Return s평균
Else
Return l합계
End If
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objValue As Object
If TextBox1.Text = "" Then
MsgBox("0 또는 1을 입력하세요")
TextBox1.Focus()
Exit Sub
End If
objValue = Param배열_활용(TextBox1.Text, 10, 20, 30, 40)
TextBox2.Text = objValue
TextBox1.Text = ""
TextBox1.Focus()
End Sub