Mesran

Hanya ingin berbagi kebaikan dan mendapatkan kebaikan yang lain.

Pemakaian Select Case Pada VB.Net 2008

Berikut merupakan listing program untuk penggunakan Select Case pada VB.Net 2008.

Semoga bermanfaat 😀

Design Program seperti tampilan di atas.

Listing Program

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        NIP.Items.Add("001")
        NIP.Items.Add("002")
        NIP.Items.Add("003")

        Gol.Items.Add("IIIA")
        Gol.Items.Add("IIIB")
        Gol.Items.Add("IIIC")
        Gol.Items.Add("IIID")
        Gol.Items.Add("IVA")

        Jabatan.Items.Add("KaBag")
        Jabatan.Items.Add("KaSub")

        btnHapus_Click(sender, e)
    End Sub

    Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapus.Click
        NIP.Text = ""
        Nama.Text = ""
        Gol.Text = ""
        Jabatan.Text = ""
        Gaji.Text = ""
        Tunjangan.Text = ""
        Total.Text = ""
    End Sub

    Private Sub Jabatan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Jabatan.SelectedIndexChanged
        Select Case Jabatan.Text
            Case "KaBag"
                Tunjangan.Text = 1500000
            Case "KaSub"
                Tunjangan.Text = 1000000
            Case Else
                Tunjangan.Text = 0
        End Select
    End Sub

    Private Sub Gol_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Gol.SelectedIndexChanged
        Select Case Gol.Text
            Case "IIIA"
                Gaji.Text = 2500000
            Case "IIIB"
                Gaji.Text = 2750000
            Case "IIIC"
                Gaji.Text = 3500000
            Case "IVA"
                Gaji.Text = 4500000
            Case Else
                Gaji.Text = 0
        End Select

    End Sub

    Private Sub NIP_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles NIP.SelectedValueChanged
        Select Case NIP.Text
            Case "001"
                Nama.Text = "Mesran"
            Case "002"
                Nama.Text = "Fahmy"
            Case "003"
                Nama.Text = "Surya Nasution"
            Case Else
                Nama.Text = ""
        End Select
    End Sub

    Private Sub btnProses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProses.Click
        Total.Text = Val(Gaji.Text) + Val(Tunjangan.Text)
    End Sub
End Class

Penjelasan :

Gol.Items.Add("IIIA") --> bertujuan untuk memasukkan item IIIA ke dalam combobox
btnHapus_Click(sender, e) --> untuk memanggil button btnHapus
Untuk membuat event click (seperti di vb tetapi beda nama) anda harus memilih
SelectedValueChanged yang cara kerjanya sama dengan event Click di VB 6 

Berikut hasilnya.



Bagaimana secara garis besar perintahnya sama dengan VB6 kan? :D
Advertisements

Filed under: VS2008,

One Response

  1. […] PDF File Name: Pemakaian select case pada vb.net 2008 | mesran Source: mesran.wordpress.com » DOWNLOAD « […]

Terima kasih telah memberikan komentar anda.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives Per Tahun

%d bloggers like this: