Halaman

Minggu, 23 Desember 2012



TUGAS
A.     FUNCTION DENGAN RETURN VALUE BERUPA ARRAY

Langkah-langkah
a.  Desain form seperti dibawah ini:




b.  Lalu masukan listing programnya seperti dibawah ini;

PublicClassForm4
PrivateFunction fstat(ByValParamArray args() AsObject) AsSingle()
Dim hasil(3) AsSingle
Dim i AsInteger
For i = 0 To UBound(args)
                hasil(0) = hasil(0) + args(i)
If i = 0 Then
                        hasil(1) = args(i)
                hasil(2) = args(i)
EndIf
If hasil(1) > args(i) Then hasil(1) = args(i)
If hasil(2) < args(i) Then hasil(2) = args(i)
Next i
Return hasil
EndFunction

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim statistik AsSingle() = fstat(21, 12, 4, 8, 7, 20, 5)
        TextBox1.Text = statistik(0)
        TextBox1.Text = statistik(0)
        TextBox2.Text = statistik(1)
        TextBox2.Text = statistik(1)
        TextBox3.Text = statistik(2)
        TextBox3.Text = statistik(2)

EndSub
EndClass


c.       Kemudian di run,Setelah di Run klik tombol hitung hasilnya seperti berikut:

B.     OVERLOADING FUNCTION
Langkah-langkah
a.      Desain form seperti dibawah ini


PublicClassForm5

Function hitung(ByVal bil1 AsInteger, ByVal bil2 AsInteger) AsInteger
        hitung = bil1 + bil2
EndFunction

Function hitung(ByVal bil1 AsInteger, ByVal bil2 AsInteger, ByVal bil3 AsInteger) AsInteger
        hitung = bil1 + bil2 + bil3
EndFunction

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = hitung(23, 10, 30)
EndSub

EndClass

b.      Setelah di run dan di klik hitung hasilnya seperti dibawah ini:


Sabtu, 08 Desember 2012

TUGAS 7
  1. Listing program untuk tugas ke 7
Public Class Form1

Private Sub Tugas1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tugas1ToolStripMenuItem.Click
Form3.MdiParent = Me
Form2.MdiParent = Me
Form2.Show()
Form3.Show()

End Sub

Private Sub Tugas2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tugas2ToolStripMenuItem.Click
Form2.MdiParent = Me
Form4.MdiParent = Me
Form2.Show()
Form4.Show()

End Sub

Private Sub Tugas3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tugas3ToolStripMenuItem.Click
Form4.MdiParent = Me
Form3.MdiParent = Me
Form4.Show()
Form3.Show()
End Sub

Private Sub Latihan1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Latihan1ToolStripMenuItem.Click
Form3.MdiParent = Me
Form3.Show()
End Sub

Private Sub Latihan2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Latihan2ToolStripMenuItem.Click
Form4.MdiParent = Me
Form4.Show()

End Sub

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

Private Sub CasadeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CasadeToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.Cascade)
Form2.Show()
Form3.Show()
End Sub

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

Private Sub TileVerticalToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TileVerticalToolStripMenuItem1.Click
Me.LayoutMdi(MdiLayout.TileVertical)
End Sub

Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Me.LayoutMdi(Windows.Forms.MdiLayout.TileHorizontal)

End Sub

Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
Me.LayoutMdi(MdiLayout.TileVertical)
End Sub

Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
Me.LayoutMdi(MdiLayout.Cascade)
End Sub
End Class


Pengaturan untuk MDI Child agar di buat
  1. Cascade
  2. Horizontal
  3. Vertical
Langkah-langkah
  1. Pertama kita buat MDI form agar dapat menampilkan beberapa form
  2. Kedua Pada masing-masing form pada properties pilih IsMdiContair yang awalnya false kita rubah menjadi true
  3. Ketiga kita debug

Tampilan utama setelah di run

  1. Kemudian pilih tugas> tugas1

Tampilan setelah kita pilih tugas1
  1. Agar tampilan berubah menjadi cascade kita pilih windows kemudian pilih cascade / kita pilih button sebelah kanan 
     
Tampilan setelah kita pilih cascade
  1. tampilan berubah menjadi horizontal kita pilih windows kemudian pilih horizontal / kita pilih button sebelah kanan 
     
Tampilan setelah kita pilih horizontal
  1. tampilan berubah menjadi vertical kita pilih windows kemudian pilih vertical/ kita pilih button sebelah kanan 

     
Tampilan setelah kita pilih vertical


Terima kasihhhhhhhhh


Senin, 12 November 2012

tugas 4


. program pilihan bahasa
buatlah desain program seperti dibawah ini

 Lalu isi coding nya seperti ini

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim control As Windows.Forms.CheckBox
        TextBox1.Text = ""
        For Each control In Me.GroupBox1.Controls
            If control.Checked = True Then
                TextBox1.Text &= control.Text & ","
            End If
        Next
        TextBox1.Text = Microsoft.VisualBasic.Left(TextBox1.Text, Len(TextBox1.Text) - 1)
    End Sub

End Class

jalankan Program ini dan pilihlah bahasa dan kemudian proses maka akan seperti dibawah ini












2.Program Pasangan Hidup
Buatlah desain program seperti dibawah ini











dan Isi coding nya seperti dibawah ini


Public Class Form1

    Private Sub BtTutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtTutup.Click
        Me.Close()

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.Enabled = False
    End Sub

    Private Sub RdKawin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RdKawin.CheckedChanged
        If RdPria.Checked = True Then
            If RdKawin.Checked = True Then
                TextBox1.Text = "Anda Sudah Memiliki Seorang Istri"
            End If
        ElseIf RdWanita.Checked = True Then
            If RdWanita.Checked = True Then
                TextBox1.Text = "Anda Sudah Memiliki Seorang Suami"
            End If
        End If
    End Sub



    Private Sub RdTidakKawin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RdTidakKawin.CheckedChanged
        If RdPria.Checked = True Then
            If RdTidakKawin.Checked = True Then
                TextBox1.Text = "Anda Harus Mencari Seorang Istri"
            End If
        ElseIf RdWanita.Checked = True Then
            If RdWanita.Checked = True Then
                TextBox1.Text = "Anda Harus Mencari Seorang Suami"
            End If
        End If
    End Sub


    Private Sub RdPria_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RdPria.CheckedChanged
        If RdKawin.Checked = True Then
            If RdPria.Checked = True Then
                TextBox1.Text = "Anda Sudah Memiliki Seorang Istri"
            End If
        ElseIf RdTidakKawin.Checked = True Then
            If RdPria.Checked = True Then
                TextBox1.Text = "Anda Harus Mencari Seorang Istri"
            End If
        End If

    End Sub

    Private Sub RdWanita_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RdWanita.CheckedChanged
        If RdKawin.Checked = True Then
            If RdWanita.Checked = True Then
                TextBox1.Text = "Anda Sudah Memiliki Seorang Suami"
            End If
        ElseIf RdTidakKawin.Checked = True Then
            If RdWanita.Checked = True Then
                TextBox1.Text = "Anda Harus Mencari Seorang Suami"
            End If
        End If

    End Sub
End Class

jalankan Programnya pilih pria dan kawin maka akan muncul ditextbox anda sudah memiliki istri
seperti dibawah ini













3 .Program Listbox
Buatlah desain program seperti dibawah ini


dan Isi coding nya seperti dibawah ini


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim control As Windows.Forms.ListBox
        TextBox1.Text = TextBox1.Text
        TextBox1.Text = ListBox1.Items.Add(TextBox1.Text)
        TextBox1.Text = TextBox1.Text
        TextBox1.Text = ListBox1.Items.Add(TextBox1.Text)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        For bil = 1 To 10
            ListBox1.Items.Add(bil)
        Next
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ListBox1.Text = ListBox2.Items.Add(ListBox1.Text)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        ListBox1.SelectionMode = SelectionMode.MultiExtended
        Dim i, j As Integer
        j = ListBox1.Items.Count
        For i = 0 To j - 1
            Try
                ListBox2.Items.Add(ListBox1.Items(ListBox1.SelectedIndices(i)))
            Catch ex As Exception
                j -= 1
            End Try
        Next
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        ListBox1.SelectionMode = SelectionMode.MultiExtended

        Dim Jumlah As Integer = ListBox1.Items.Count
        For i = 0 To Jumlah - 1
            ListBox2.Items.Add(ListBox1.Items(i))
        Next
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        ListBox2.SelectionMode = SelectionMode.One

        ListBox2.Items.Remove(ListBox2.SelectedItem)
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        ListBox2.SelectionMode = SelectionMode.MultiExtended
        Dim i, j As Integer
        j = ListBox2.Items.Count
        For i = 0 To j - 1
            Try
                ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
            Catch ex As Exception
                j -= 1
            End Try
        Next
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        ListBox2.Items.Clear()
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Me.Close()
    End Sub
End Class