Minggu, 07 Desember 2014

Pemrograman Pencarian Harga Kaset Menggunakan Microsoft Visual Studio 2010












Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Kode.Items.Add("A1001")
        Kode.Items.Add("A1002")
        Kode.Items.Add("A2001")
        Kode.Items.Add("A2002")
        Kode.Items.Add("A3001")
        Kode.Items.Add("S1001")
        Kode.Items.Add("S1002")
        Kode.Items.Add("F1001")
        Kode.Items.Add("F1002")

        Jenis.Items.Add("Arcade")
        Jenis.Items.Add("Simulasi")
        Jenis.Items.Add("First Person Shooter")

        Dim i As Integer
        For i = 1 To 2
            JumlahKaset.Items.Add(i)
        Next
        For i = 1 To 100
            JumlahBeli.Items.Add(i)
        Next i
    End Sub

    Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode.SelectedIndexChanged

        Dim x As String
        x = Mid(Kode.Text, 1, 1)
        If x = "A" Then
            Jenis.Text = "Arcade"
        ElseIf x = "S" Then
            Jenis.Text = "Simulasi"
        ElseIf x = "F" Then
            Jenis.Text = "First Person Shooter"
        End If

        x = Mid(Kode.Text, 2, 1)
        JumlahKaset.Text = x

        Harga.Text = x * 10000

        If Kode.Text = "A1001" Then
            Nama.Text = "GTA San Andreas"
        ElseIf Kode.Text = "A1002" Then
            Nama.Text = "Worm"
        ElseIf Kode.Text = "A2001" Then
            Nama.Text = "Devil May Cry"
        ElseIf Kode.Text = "A2002" Then
            Nama.Text = "Naruto Shippuden 6"
        ElseIf Kode.Text = "A3001" Then
            Nama.Text = "GTA IV"
        ElseIf Kode.Text = "S1001" Then
            Nama.Text = "Train Simulator"
        ElseIf Kode.Text = "S1002" Then
            Nama.Text = "Flight Simulator"
        ElseIf Kode.Text = "F1001" Then
            Nama.Text = "Counter Strike"
        ElseIf Kode.Text = "F1002" Then
            Nama.Text = "Ghost Recon"
        End If
    End Sub

    Private Sub JumlahBeli_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JumlahBeli.SelectedIndexChanged
        TotalHarga.Text = JumlahBeli.Text * Harga.Text
    End Sub

    Private Sub TotalHarga_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TotalHarga.TextChanged
        If JumlahBeli.Text > 10 Then
            Diskon.Text = TotalHarga.Text * 0.1
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Bayar.Text = TotalHarga.Text - Diskon.Text
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Kode.Text = ""
        Nama.Text = ""
        Jenis.Text = ""
        JumlahKaset.Text = 0
        Harga.Text = 0
        JumlahBeli.Text = 0
        TotalHarga.Text = 0
        Diskon.Text = 0
        Bayar.Text = 0
    End Sub

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