Contoh select case 8 dan Fungsi IF



Pemakaian select  case 8
Fungsi IF
Nik berisi
K1001
K2003
S1001
S2002
S3003
A1001
A2002
A3003
 Private sub MK_selectedIndexChange()
                Dim x As String
                X=microsoft.visualbasic.left(NIK.text,1)
Select Case X
Case “k” : bagian.text = “keterangan”
Case “a” : bagian.text= “administrasi”
Case “s” : bagian.text= “Security”
End select
End sub

Contoh
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        NIK.Items.Add("K1001")
        NIK.Items.Add("K2003")
        NIK.Items.Add("S1001")
        NIK.Items.Add("S2002")
        NIK.Items.Add("S3003")
        NIK.Items.Add("A1001")
        NIK.Items.Add("A2002")
        NIK.Items.Add("A3003")
        Golongan.Items.Add("IIIA")
        Golongan.Items.Add("IIIB")
        Golongan.Items.Add("IIIC")
    End Sub

    Private Sub NIK_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NIK.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(NIK.Text, 2)
        Select Case x
            Case "K1" : Nama.Text = "gue"
            Case "K2" : Nama.Text = "elo"
            Case "S1" : Nama.Text = "loe"
            Case "S2" : Nama.Text = "hai"
            Case "S3" : Nama.Text = "wow"
            Case "A1" : Nama.Text = "saya"
            Case "A2" : Nama.Text = "itu"
            Case "A3" : Nama.Text = "yeye"
        End Select
        x = Microsoft.VisualBasic.Left(NIK.Text, 2)
        Select Case x
            Case "K1" : Bagian.Text = "Keuangan"
            Case "K2" : Bagian.Text = "Keuangan"
            Case "A1" : Bagian.Text = "Administrasi"
            Case "A2" : Bagian.Text = "Administrasi"
            Case "A3" : Bagian.Text = "Administrasi"
            Case "S1" : Bagian.Text = "Security"
            Case "S2" : Bagian.Text = "Security"
            Case "S3" : Bagian.Text = "Security"
        End Select
        x = Microsoft.VisualBasic.Left(NIK.Text, 2)
        Select Case x
            Case "K1" : Jabatan.Text = "Direktur"
            Case "K2" : Jabatan.Text = "sekretaris"
            Case "A1" : Jabatan.Text = "Direktur"
            Case "A2" : Jabatan.Text = "sekretaris"
            Case "A3" : Jabatan.Text = "wakil sekretaris"
            Case "S1" : Jabatan.Text = "ketua"
            Case "S2" : Jabatan.Text = "anggota1"
            Case "S3" : Jabatan.Text = "kernet1"
        End Select
    End Sub

    Private Sub Golongan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Golongan.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Right(Golongan.Text, 1)
        Select Case x
            Case "A" : Gaji.Text = "$500"
            Case "B" : Gaji.Text = "300000"
            Case "C" : Gaji.Text = "35000"
        End Select
    End Sub


End Class
0 Komentar untuk "Contoh select case 8 dan Fungsi IF"

 
Copyright © 2014 Damai7 - All Rights Reserved
Template By. Konsen Fokus