Senin, 17 Desember 2012

Tugas Pemrograman Visual 7

MENU, TOOLBAR, MDI FORM

Tugas kali ini tentang menu, toolbar, dan MDI form dimana kita akan membuat suatu aplikasi yang menggunakan toolbox menus & tollbars,yang disitu terdapat menu ContextMenuStrip, MenuStrip, StatusStrip, ToolStripContainer, ToolStrip yang nanti akan kita gunakan:





pada gambar diatas kita gunakan MenuStrip dan ToolStrip,diatas saya tambah kan menu latihan, tugas, dan Exit,selain dari menu standar file, edit, tools, dan help.
pada menu latihan dan tugas terdapat beberapa latihan dan tugas yang nantinya bisa kita buka,




setelah form yang telah kita buka tadi,kita bisa membuat form-form itu menjadi berurutan atau cascade,dengan mengklik icon cascade yang telah ada,dengan mengklik icon cascade maka akan menghasilkan sebagai berikut:






terdapat juga pilihan lain selain cascade yaitu horizontal dan vertical,pada icon yang telah tersedia
hasil dari icon horizontal




Hasil dari icon Vertical:




pada menu Tugas saya menggunakan showdialog,dan apabila telah dibuka maka tidak bisa membuka form lain, 





sort program:
Public Class Form1

    Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
        Form2.MdiParent = Me
        Form2.Show()
    End Sub

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

    End Sub

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

    End Sub

    Private Sub ExitToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem1.Click
        If MsgBox("Anda yakin akan keluar dari apikasi ini?", vbQuestion + vbYesNo + vbDefaultButton2, "Keluar") = MsgBoxResult.Yes Then Me.Close()
    End Sub

    Private Sub ToolStripMenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem5.Click
        Form2.ShowDialog()

    End Sub

    Private Sub ToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem6.Click
        Form3.ShowDialog()

    End Sub

    Private Sub ToolStripMenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem7.Click
        Form4.ShowDialog()

    End Sub

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

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

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


Selesai
Semoga bermanfaat
Salam Sukses !!

























Rabu, 07 November 2012

LISTBOX


1.    Buat tampilan sepertin ini













Ini codingnya :
Button1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Add(TextBox1.Text)
    End Sub

Button2
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim A As Integer
        A = 0
        Do
            A = A + 1
            ListBox1.Items.Add(A)
        Loop Until A = 10
    End Sub

Button 3
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Close()

    End Sub

Button 4
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        ListBox2.Items.Add(ListBox1.SelectedItem)
       
    End Sub


Button5
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim obj As Object
        obj = ListBox2.SelectedItem

        ListBox2.Items.Remove(obj)


    End Sub

Button6
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Dim obj As Object
        For Each obj In ListBox1.SelectedItems
            ListBox2.Items.Add(obj)
        Next

    End Sub

Button7
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        ListBox2.Items.AddRange(ListBox1.Items)

    End Sub

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

        For i As Integer = 0 To ListBox2.SelectedIndices.Count - 1
            ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
        Next
    End Sub

Button9
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        ListBox2.Items.Clear()


    End Sub


Salam SUKSES Untuk KITA Semua !!

Sabtu, 27 Oktober 2012

TUGAS PEMROGRAMAN VISUAL 3


Haii Guys..!!

Program yang pertama akan saya tampilkan adalah modifikasi dari Tugas 2 ,jadi

1.  Saat form dijalankan : semua isian tidak aktif, tombol isidata dan tutup aktif, tombol clear tidak aktif
2.  Saat ditekan tombol isi data : kodebarang, jumlahbarang, cara beli, tombol clear, aktif, tombol isi data     tidak aktif
3.  Saat ditekan combol clear sama dengan saat form dijalankan

Berikut tampilan program pada saat dijalankan :




Apabila pada saat menekan tombol isi data ,form akan aktif ,sedangkan tombol isi data tidak aktif. Seperti gambar dibawah ini  :




Dan ketika menekan tombol clear ,form akan kembali seperti pada saat pertama kali dijalankan :




Berikut kodingnya - CEKIDOT :

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a As Windows.Forms.Control

        For Each a In Me.Controls
            a.Enabled = False
            Button2.Enabled = True
            Button1.Enabled = True
        Next
       

        cmbkode.Items.Add(“SPT”)
        cmbkode.Items.Add(“SND”)
        cmbkode.Items.Add(“TST”)
        cmbkode.Items.Add(“TOP”)
        cmbkode.Items.Add(“TAS”)

    End Sub

    Private Sub cmbkode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbkode.SelectedIndexChanged
        Dim kdbarang, namabarang As String
        Dim harga As Single
        kdbarang = cmbkode.Text

        Select Case kdbarang
            Case “SPT”
                namabarang = “SEPATU”
                harga = 200000

            Case “SND”
                namabarang = “SANDAL”
                harga = 100000

            Case “TST”
                namabarang = “T-SHIRT”
                harga = 150000

            Case “TOP”
                namabarang = “TOPI”
                harga = 50000

            Case “TAS”
                namabarang = “TAS”
                harga = 200000
            
            Case Else
                namabarang = “_”
                harga = 0

        End Select
        Txtnama.Text = namabarang
        Txtharga.Text = harga
        Txtharga.Text = Format(harga, “#,#”)
    End Sub

    Private Sub Txtjumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Txtjumlah.TextChanged
        Dim total As Single

        Txttotal.Text = Val(Txtharga.Text) * Val(Txtjumlah.Text)
        Txtbayar.Text = Val(Txttotal.Text) – Val(Txtdiskon.Text)
        Txttotal.Text = Format(total, “#,#”)
    End Sub

    Private Sub Radiotunai_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radiotunai.CheckedChanged
        Txtdiskon.Text = Val(Txttotal.Text) * 10 / 100
        Txtbayar.Text = Val(Txttotal.Text) – Val(Txtdiskon.Text)
    End Sub

    Private Sub Radiokredit_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radiokredit.CheckedChanged
        Txtdiskon.Text = 0
        Txtbayar.Text = Val(Txttotal.Text) – Val(Txtdiskon.Text)
    End Sub

    Private Sub Btclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btclear.Click
        Dim a As Windows.Forms.Control

        For Each a In Me.Controls
            a.Enabled = False
            Button2.Enabled = True
            Button1.Enabled = True
        Next

        Txtbayar.Clear()
        Txtdiskon.Clear()
        Txtharga.Clear()
        Txtjumlah.Clear()
        Txtnama.Clear()
        Txttotal.Clear()
        Me.Radiotunai.Checked = False
        Me.Radiokredit.Checked = False
        cmbkode.Text = “”
    End Sub

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

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a As Windows.Forms.Control

        For Each a In Me.Controls
            a.Enabled = True
            Button1.Enabled = False
        Next
    End Sub
End Class


Program kedua adalah Puzzle

1.  Saat form dijalankan posisi angka acak
2.  Saat ditekan tombol yang terletak di dekat tombol kosong maka tombol tersebut akan menempati tombol kosong, begitu seterusnya sampai dengan angkanya tersusun dari 1 sampai 8
3.  Saat angka sudah tersusun tampilkan pesan selamat anda berhasil

Ketika form dijalankan, posisi angka acak :



Saat ditekan tombol yang terletak di dekat tombol kosong maka tombol tersebut akan menempati tombol kosong seperti gambar dibawah ini :





Saat angka sudah tersusun tampilkan pesan selamat anda berhasil !!



Berikut kodingnya - CEKIDOT :

Public Class Form1
    Dim angka(0 To 8) As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
        Dim Control As Windows.Forms.Control
        Dim number As Integer
        Dim rndnumber As Random
        rndnumber = New Random

        For Each Control In Me.Controls
            If Control.GetType.Name = “Button” Then

        number = rndnumber.Next(1, 9)
            Control.Text = number

            End If

            If btn1.Text = btn2.Text Then
            Do
                    number = rndnumber.Next(1, 9)
                    btn2.Text = number
                Loop Until btn1.Text <> btn2.Text
            End If

            If btn1.Text = btn3.Text Or btn2.Text = btn3.Text Then
                Do
                    number = rndnumber.Next(1, 9)
                    btn3.Text = number
                Loop Until btn1.Text <> btn3.Text And btn2.Text <> btn3.Text
            End If

            If btn1.Text = btn4.Text Or btn2.Text = btn4.Text Or btn3.Text = btn4.Text Then
                Do
                    number = rndnumber.Next(1, 9)
                    btn4.Text = number
                Loop Until btn1.Text <> btn4.Text And btn2.Text <> btn4.Text And btn3.Text <> btn4.Text
            End If

            If btn1.Text = btn5.Text Or btn2.Text = btn5.Text Or btn3.Text = btn5.Text Or btn4.Text = btn5.Text Then
                Do
                    number = rndnumber.Next(1, 9)
                    btn5.Text = number
                Loop Until btn1.Text <> btn5.Text And btn2.Text <> btn5.Text And btn3.Text <> btn5.Text And btn4.Text <> btn5.Text
            End If

            If btn1.Text = btn6.Text Or btn2.Text = btn6.Text Or btn3.Text = btn6.Text Or btn4.Text = btn6.Text Or btn5.Text = btn6.Text Then
                Do
                    number = rndnumber.Next(1, 9)
                    btn6.Text = number
                Loop Until btn1.Text <> btn6.Text And btn2.Text <> btn6.Text And btn3.Text <> btn6.Text And btn4.Text <> btn6.Text And btn5.Text <> btn6.Text
            End If

            If btn1.Text = btn7.Text Or btn2.Text = btn7.Text Or btn3.Text = btn7.Text Or btn4.Text = btn7.Text Or btn5.Text = btn7.Text Or btn6.Text = btn7.Text Then
                Do
                    number = rndnumber.Next(1, 9)
                    btn7.Text = number
                Loop Until btn1.Text <> btn7.Text And btn2.Text <> btn7.Text And btn3.Text <> btn7.Text And btn4.Text <> btn7.Text And btn5.Text <> btn7.Text And btn6.Text <> btn7.Text
            End If

            If btn1.Text = btn8.Text Or btn2.Text = btn8.Text Or btn3.Text = btn8.Text Or btn4.Text = btn8.Text Or btn5.Text = btn8.Text Or btn6.Text = btn8.Text Or btn7.Text = btn8.Text Then
                Do
                    number = rndnumber.Next(1, 9)
                    btn8.Text = number
                Loop Until btn1.Text <> btn8.Text And btn2.Text <> btn8.Text And btn3.Text <> btn8.Text And btn4.Text <> btn8.Text And btn5.Text <> btn8.Text And btn6.Text <> btn8.Text And btn7.Text <> btn8.Text
            End If

            If btn9.Text <> “” Then
                btn9.Text = “”
            End If
        Next
    End Sub

    Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
        If btn2.Text = “” Then
            btn2.Text = btn1.Text
            btn1.Text = “”
        ElseIf btn4.Text = “” Then
            btn4.Text = btn1.Text
            btn1.Text = “”
        Else
            btn1.Text = btn1.Text
        End If

        If btn1.Text = “1″ And btn2.Text = “2″ And btn3.Text = “3″ And btn4.Text = “4″ And btn5.Text = “5″ And btn6.Text = “6″ And btn7.Text = “7″ And btn8.Text = “8″ And btn9.Text = “” Then
            MessageBox.Show(“SELAMAT ANDA BERHASIL”)
        End If
    End Sub

    Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
        If btn1.Text = “” Then
            btn1.Text = btn2.Text
            btn2.Text = “”
        ElseIf btn3.Text = “” Then
            btn3.Text = btn2.Text
            btn2.Text = “”
        ElseIf btn5.Text = “” Then
            btn5.Text = btn2.Text
            btn2.Text = “”
        Else
            btn2.Text = btn2.Text
        End If

        If btn1.Text = “1″ And btn2.Text = “2″ And btn3.Text = “3″ And btn4.Text = “4″ And btn5.Text = “5″ And btn6.Text = “6″ And btn7.Text = “7″ And btn8.Text = “8″ And btn9.Text = “” Then
            MessageBox.Show(“SELAMAT ANDA BERHASIL”)
        End If
    End Sub

    Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
        If btn2.Text = “” Then
            btn2.Text = btn3.Text
            btn3.Text = “”
        ElseIf btn6.Text = “” Then
            btn6.Text = btn3.Text
            btn3.Text = “”
        Else
            btn3.Text = btn3.Text
        End If

        If btn1.Text = “1″ And btn2.Text = “2″ And btn3.Text = “3″ And btn4.Text = “4″ And btn5.Text = “5″ And btn6.Text = “6″ And btn7.Text = “7″ And btn8.Text = “8″ And btn9.Text = “” Then
            MessageBox.Show(“SELAMAT ANDA BERHASIL”)
        End If
    End Sub

    Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
        If btn1.Text = “” Then
            btn1.Text = btn4.Text
            btn4.Text = “”
        ElseIf btn7.Text = “” Then
            btn7.Text = btn4.Text
            btn4.Text = “”
        ElseIf btn5.Text = “” Then
            btn5.Text = btn4.Text
            btn4.Text = “”
        Else
            btn4.Text = btn4.Text
        End If

        If btn1.Text = “1″ And btn2.Text = “2″ And btn3.Text = “3″ And btn4.Text = “4″ And btn5.Text = “5″ And btn6.Text = “6″ And btn7.Text = “7″ And btn8.Text = “8″ And btn9.Text = “” Then
            MessageBox.Show(“SELAMAT ANDA BERHASIL”)
        End If
    End Sub

    Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
        If btn2.Text = “” Then
            btn2.Text = btn5.Text
            btn5.Text = “”
        ElseIf btn4.Text = “” Then
            btn4.Text = btn5.Text
            btn5.Text = “”
        ElseIf btn8.Text = “” Then
            btn8.Text = btn5.Text
            btn5.Text = “”
        ElseIf btn6.Text = “” Then
            btn6.Text = btn5.Text
            btn5.Text = “”
        Else
            btn5.Text = btn5.Text
        End If

        If btn1.Text = “1″ And btn2.Text = “2″ And btn3.Text = “3″ And btn4.Text = “4″ And btn5.Text = “5″ And btn6.Text = “6″ And btn7.Text = “7″ And btn8.Text = “8″ And btn9.Text = “” Then
            MessageBox.Show(“SELAMAT ANDA BERHASIL”)
        End If
    End Sub

    Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
        If btn9.Text = “” Then
            btn9.Text = btn6.Text
            btn6.Text = “”
        ElseIf btn3.Text = “” Then
            btn3.Text = btn6.Text
            btn6.Text = “”
        ElseIf btn5.Text = “” Then
            btn5.Text = btn6.Text
            btn6.Text = “”
        Else
            btn6.Text = btn6.Text
        End If

        If btn1.Text = “1″ And btn2.Text = “2″ And btn3.Text = “3″ And btn4.Text = “4″ And btn5.Text = “5″ And btn6.Text = “6″ And btn7.Text = “7″ And btn8.Text = “8″ And btn9.Text = “” Then
            MessageBox.Show(“SELAMAT ANDA BERHASIL”)
        End If
    End Sub

    Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
        If btn8.Text = “” Then
            btn8.Text = btn7.Text
            btn7.Text = “”
        ElseIf btn4.Text = “” Then
            btn4.Text = btn7.Text
            btn7.Text = “”
        Else
            btn7.Text = btn7.Text
        End If

        If btn1.Text = “1″ And btn2.Text = “2″ And btn3.Text = “3″ And btn4.Text = “4″ And btn5.Text = “5″ And btn6.Text = “6″ And btn7.Text = “7″ And btn8.Text = “8″ And btn9.Text = “” Then
            MessageBox.Show(“SELAMAT ANDA BERHASIL”)

        End If
    End Sub

    Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
        If btn9.Text = “” Then
            btn9.Text = btn8.Text
            btn8.Text = “”
        ElseIf btn7.Text = “” Then
            btn7.Text = btn8.Text
            btn8.Text = “”
        ElseIf btn5.Text = “” Then
            btn5.Text = btn8.Text
            btn8.Text = “”
        Else
            btn8.Text = btn8.Text
        End If

        If btn1.Text = “1″ And btn2.Text = “2″ And btn3.Text = “3″ And btn4.Text = “4″ And btn5.Text = “5″ And btn6.Text = “6″ And btn7.Text = “7″ And btn8.Text = “8″ And btn9.Text = “” Then
            MessageBox.Show(“SELAMAT ANDA BERHASIL”)
        End If
    End Sub

    Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
        If btn8.Text = “” Then
            btn8.Text = btn9.Text
            btn9.Text = “”
        ElseIf btn6.Text = “” Then
            btn6.Text = btn9.Text
            btn9.Text = “”
        Else
            btn9.Text = btn9.Text
        End If

        If btn1.Text = “1″ And btn2.Text = “2″ And btn3.Text = “3″ And btn4.Text = “4″ And btn5.Text = “5″ And btn6.Text = “6″ And btn7.Text = “7″ And btn8.Text = “8″ And btn9.Text = “” Then
            MessageBox.Show(“SELAMAT ANDA BERHASIL”)
        End If
    End Sub

   
End Class




SEMOGA  BERMANFAAT







Rabu, 24 Oktober 2012

TUGAS PEMROGRAMAN VISUAL



Nama  : MUSTIKA DIAN PRATIWI
Kelas  : TI 11 Sore
NIM   : 11.11.1950


  • Tugas 1
  • Tugas 2
          http://mustika-pratiwi.blogspot.com/2012/10/pemrograman-visual-2.html
  • Tugas 3
          http://mustika-pratiwi.blogspot.com/2012/10/tugas-pemrograman-visual-3.html
  • Tugas 4
          http://mustika-pratiwi.blogspot.com/2012/11/listbox.html
  • Tugas 7
          http://mustika-pratiwi.blogspot.com/2012/12/tugas-pemrograman-visual-7.html

  • Tugas 8
          http://mustika-pratiwi.blogspot.com/2013/01/tugas-8.html

  • Tugas 9
          http://mustika-pratiwi.blogspot.com/2013/01/koneksi-link-visual-basic-menggunakan.html