Sabtu, 22 Desember 2012

Tugas Visual Studio ke - 6

Function dengan return value berupa Array

1. Buat formnya terlebih dahulu. Kita buat seperti ini




2. Masukkan listing atau inputannya sebagai berikut :

Public Class Form1
    Private Function fstat(ByVal ParamArray args() As Object) As Single()
        Dim hasil(3) As Single
        Dim i As Integer
        For i = 0 To UBound(args)
            hasil(0) = hasil(0) + args(i)
            If i = 0 Then
                hasil(1) = args(i)
                hasil(2) = args(i)
            End If
            If hasil(1) > args(i) Then hasil(1) = args(i)
            If hasil(2) < args(i) Then hasil(2) = args(i)
        Next
        fstat = hasil
    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim statistik As Array = fstat(1, 6, 2, 7, 3, 9, 4, 10, 8, 5)
        TextBox1.Text = statistik(0)
        TextBox2.Text = statistik(1)
        TextBox3.Text = statistik(2)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class



3. Lalu klik pada "Debug" untuk menjalankan programnya, untuk me"run".

4. Lalu akan muncul seperti ini







0 komentar:

Posting Komentar

Template by:

Free Blog Templates