Sabtu, 01 Juni 2013

Yuk! Belajar Pemrograman Visual Basic dot Net Di Mesran.Net

Selesaikanlah Kasus Berikut ini : JUDUL SOAL ANDA DAN DI LINK KE POSTINGAN SOAL

Berikut jawabannya terlihat seperti dibawah ini: 

Public Class Form1



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        isitabel()
        No.Text = ""
        Kode.Text = ""
        Nama.Text = ""
        Merk.Text = ""
        Harga.Text = ""
        Jumlah.Text = ""
        Total.Text = ""
    End Sub

    Private Sub BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnKeluar.Click
        End
    End Sub
    Sub Isitabel()
        Dim lst As New ListViewItem
        lst.Text = No.Text
        lst.SubItems.Add(Kode.Text)
        lst.SubItems.Add(Nama.Text)
        lst.SubItems.Add(Merk.Text)
        lst.SubItems.Add(Harga.Text)
        lst.SubItems.Add(Jumlah.Text)
        lst.SubItems.Add(Total.Text)
        LV.Items.Add(lst)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BuatTabel()
        Kode.Items.Add("TS001")
        Kode.Items.Add("TS002")
        Kode.Items.Add("VG001")
        Kode.Items.Add("VG002")

    End Sub
    Sub BuatTabel()
        LV.Columns.Add("No. Pembeli", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Kode Barang", 180, HorizontalAlignment.Left)
        LV.Columns.Add("Nama Barang", 100, HorizontalAlignment.Left)
        LV.Columns.Add("Merk", 90, HorizontalAlignment.Center)
        LV.Columns.Add("Harga", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Jumlah Beli", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Total Harga", 100, HorizontalAlignment.Center)
        LV.View = View.Details
        LV.GridLines = True
        LV.FullRowSelect = True
    End Sub

    Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(Kode.Text, 2)
        Select Case x
            Case "TS" : Merk.Text = "Toshiba"
            Case "VG" : Merk.Text = "V-Gen"
        End Select

        Dim x2 As String
        x2 = Microsoft.VisualBasic.Right(Kode.Text, 3)

        If x = "TS" And x2 = "001" Then
            Harga.Text = "105000"
        ElseIf x = "TS" And x2 = "002" Then
            Harga.Text = "75000"
        ElseIf x = "VG" And x2 = "001" Then
            Harga.Text = "90000"
        ElseIf x = "VG" And x2 = "002" Then
            Harga.Text = "60000"
        End If

        x = Microsoft.VisualBasic.Right(Kode.Text, 3)
        Select Case x
            Case "001" : Nama.Text = "Flashdisk 4 GB"
            Case "002" : Nama.Text = "Flashdisk 2 GB"
        End Select
    End Sub

    Private Sub Jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jumlah.KeyPress
        If Asc(e.KeyChar) = 13 Then
            Total.Text = Harga.Text * Jumlah.Text
            Total.Enabled = False
            Total.BackColor = Color.Cyan
        End If
    End Sub

    Private Sub Jumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Jumlah.TextChanged

    End Sub

    Private Sub BtnBersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBersih.Click
        No.Text = ""
        Kode.Text = ""
        Nama.Text = ""
        Merk.Text = ""
        Harga.Text = ""
        Jumlah.Text = ""
        Total.Text = ""
    End Sub

    Private Sub BtnHapusSemuaData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHapusSemuaData.Click
        LV.Items.Clear()
    End Sub

    Private Sub BtnHapusDataPilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHapusDataPilih.Click
        LV.Items.Remove(LV.SelectedItems(0))
    End Sub
End Class

Hasil Program


Demikianlah postingan saya Nama : Iswahyuni NPM : 1111706

Selamat Belajar Pemrograman VB Net

Tidak ada komentar:

Posting Komentar