Senin, 17 Desember 2012

Tugas 5







Kodingnya sebagai berikut :
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim statistik As Single() = 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 Function fstat(ByVal ParamArray arg() As Object) As Single()
        Dim hasil(3) As Single
        Dim i As Integer
        For i = 0 To UBound(arg)
            hasil(0) = hasil(0) + arg(i)
            If i = 0 Then

                hasil(1) = arg(i)
                hasil(2) = arg(i)
            End If
            If hasil(1) < arg(i) Then hasil(1) = arg(i)
            If hasil(2) > arg(i) Then hasil(2) = arg(i)
        Next i
        Return hasil
    End Function
End Class
Pada If hasil(1) > arg(i) Then hasil(1) = arg(i)
      If hasil(2) < arg(i) Then hasil(2) = arg(i)
Akan menghasilkan hasil yang salah bahkan terbalik, ditemukannya adalah nilai terbesarnya 1 dan terkecilnya 10, maka dari itu koding di atas d rubah jadi begini
If hasil(1) < arg(i) Then hasil(1) = arg(i)
If hasil(2) > arg(i) Then hasil(2) = arg(i)
Maksud dari koding di atas adalah,fstat mengandung angka 1,6,2,7,3,9,4,10,8,5 dan proses pengerjaannya , hsil 0 = hasil 0 + arg(1) dan hasil 1 = 1
Jika hasil 1 < dari arg(i), hasil 2 > dari arg(i)  maksudnya daftar di fstat, maka akan melakukan proses pengulangan terus , kembali ke atas dan kembali ke atas seterusnya sampai menemukan hasil yang benar yakni nilai terbesar 10 dan nilai terkecil 1 . 
 
 Overloading function
Public Class Form4
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = hitung(1, 2, 3)
    End Sub
    Function hitung(ByVal bil1 As Integer, ByVal bil2 As Integer) As Integer
        hitung = bil1 + bil2
    End Function
    Function hitung(ByVal bil1 As Integer, ByVal bil2 As Integer, ByVal bil3 As Integer) As Integer
        hitung = bil1 + bil2 + bil3
    End Function
End Class

saat di tekan button hitung makan akan keluar hasilnya = 6.
Dikarenakan menjumlahkan bil1+bil2+bil3.
 
 

Senin, 10 Desember 2012

TUGAS 4

TUGAS PEMROGRAMAN VISUAL 4

Kali ini saya akan menampilkan cara membuat tampilan layout program yang saya buat... 
langsung saja disimak . . .^_^ . . .





Public Class Form1
   

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

    End Sub

    Private Sub KeluarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KeluarToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub Latihan11ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Latihan11ToolStripMenuItem1.Click

        latihan_1_1.MdiParent = Me
        latihan_1_1.Show()
    End Sub

    Private Sub Latihan22ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Latihan22ToolStripMenuItem2.Click
        Latihan_1_2.MdiParent = Me


        Latihan_1_2.Show()
    End Sub

   
    Private Sub Latihan11ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Latihan11ToolStripMenuItem.Click
        Tugas_1_1.MdiParent = Me
        Tugas_1_1.Show()
    End Sub

    Private Sub Latihan22ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Latihan22ToolStripMenuItem.Click
        Tugas_1_2.MdiParent = Me
        Tugas_1_2.Show()
    End Sub

    Private Sub CascadeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CascadeToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.Cascade)

    End Sub

    Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TileHorizontalToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.TileHorizontal)

    End Sub

    Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TileVerticalToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.TileVertical)

    End Sub
End Class