soal dan penyelesaian Visual Basic
Jawaban
Listing Kode Dari Program Tersebut.
Public Class Form1
    'Dobel click form lalu masukan kode berikut
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i = 1 To 31 'untuk i dari 1 sampai 31
            cmbtgl.Items.Add(i) 'tambahkan pada commbobox tgl dari 1 sampai 31
        Next
        'inisialisai bln sebagai array string
        Dim bln() As String = {"januari", "Februari", "Maret", "April", "Mei", "Juni",
                             "Juli", "Agustus", "September", "Oktober", "November", "Desember"}
        For Each a In bln 'untuk setiap a dalam bln
            cmbbln.Items.Add(a) 'tambahkan a pada combobox bln
        Next
        Dim thn() As String = {"2010", "2011", "2012"}
        For Each a In thn
            cmbthn.Items.Add(a)
        Next
        Dim jenislapangan() As String = {"Matras", "Reguler", "Rumput"}
        For Each lapang In jenislapangan
            cmbjl.Items.Add(lapang)
        Next
    End Sub
    'doble click check box sepatu lalu masukan kode dibawah.a..
    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = True Then 'jika check sepatu dichecklist
            txtsepatu.Text = 50000 'text sepatu 50000
        Else 'jika tidak di check list
            txtsepatu.Text = 0 'textsepatu menjadi 0
        End If
    End Sub
    'doble clik checkbok kostum
    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        If CheckBox2.Checked = True Then 'jika check kostum di cheklist
            txtkostum.Text = 45000 'text kostum = 45000
        Else 'jika tidak dicheck
            txtkostum.Text = 0  'text kostum menjadi 0
        End If
    End Sub
    'masukan pada kode berikut pada combobox jenis lapangan
    Private Sub cmbjl_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbjl.Click
        If rdoindoor.Checked = True Then
            If cmbjl.Text = "Reguler" Then
                txtbl.Text = 300000
            ElseIf cmbjl.Text = "Matras" Then
                txtbl.Text = 250000
            Else
                txtbl.Text = 200000
            End If
        Else
            If cmbjl.Text = "Reguler" Then
                txtbl.Text = 250000
            ElseIf cmbjl.Text = "Matras" Then
                txtbl.Text = 200000
            Else
                txtbl.Text = 150000
            End If
        End If
    End Sub
    'masukan pada option indoor
    Private Sub rdoindoor_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdoindoor.CheckedChanged
        'saat pergantian pilihan
        cmbjl.Text = "" 'combobox jenis lapangan kosong
        txtbl.Text = "" 'text biaya lapangan kosong
    End Sub
    'masukan pada button hitung
    Private Sub btnHitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHitung.Click
        txtth.Text = Val(txtls.Text) * Val(txtbl.Text) + Val(txtls.Text) * (Val(txtsepatu.Text) + Val(txtkostum.Text))
    End Sub
    'masukan pada text uang bayar
    Private Sub txtub_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtub.TextChanged
        txtuk.Text = Val(txtub.Text) - Val(txtth.Text)
    End Sub
    'masukan pada button ulang
    Private Sub btnulang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnulang.Click
        'menghapus seluru teks pada form
        txtnu.Text = ""
        txtnp.Text = ""
        txtls.Text = ""
        CheckBox1.Checked = False
        CheckBox2.Checked = False
        txtsepatu.Text = ""
        txtkostum.Text = ""
        txtbl.Text = ""
        txtth.Text = ""
        txtuk.Text = ""
        txtub.Text = ""
        txtnu.Focus()
    End Sub
    'masukan pada button keluar
    Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
        'jika pesan berikut keluar dan klik yes
        If MessageBox.Show("Yakin akan Keluar ..?", "OOOPS..!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
            Application.Exit() 'maka aplikasi keluar
        End If
    End Sub
  
End Class
 
 
 
Label: , edit post
0 Responses

Posting Komentar

terima kasih atas kunjungannya, jangan Lupa Komentar Ya :)


Powered By FISHBONE
  • Followers

  • Entri Populer

Vhanbokle.blogspot.com