RSS

contoh VB sederhana

Kalkulator Ringkas


#coding
Public Class Form2

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        TextBox2.Focus()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If ComboBox1.Text = "+" Then
            TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
        ElseIf ComboBox1.Text = "-" Then
            TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
        ElseIf ComboBox1.Text = "*" Then
            TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
        ElseIf ComboBox1.SelectedText = "/" Then
            TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
        ElseIf ComboBox1.Text = "%" Then
            TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text) / 100
        End If
    End Sub

End Class


PENGGAJIAN


*note
pada propertis textbox (name) diganti nama sesusai selera, biar mudah n ga ribet. Misal :
Gaji pokok = GP
Tunjangan = TJ
Gaji Bersih = GB
Potongan = PT
dst

#CODING

 Public Class Form1

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Select Case ComboBox1.SelectedItem
            Case "OPERATOR"
                GP.Text = 3000000
                TJ.Text = 25 / 100 * Val(GP.Text)
                PT.Text = 2 / 100 * (Val(GP.Text) + Val(TJ.Text))
            Case "STAFF"
                GP.Text = 4000000
                TJ.Text = 25 / 100 * Val(GP.Text)
                PT.Text = 3 / 100 * (Val(GP.Text) + Val(TJ.Text))
            Case Else
                GP.Text = 6000000
                TJ.Text = 25 / 100 * Val(GP.Text)
                PT.Text = 5 / 100 * (Val(GP.Text) + Val(TJ.Text))
        End Select
        GB.Focus()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        GB.Text = Val(GP.Text) + Val(TJ.Text) - Val(PT.Text)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        MessageBox.Show("yakin ni ga mau nambah", "warninggg!!!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)
        Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        NAMA.Text = ""
        GP.Clear()
        TJ.Clear()
        PT.Clear()
        GB.Clear()
        ComboBox1.Text = "--pilih--"
        NAMA.Focus()
    End Sub
End Class



PENGGAJIAN WITH NIK


*note
pada propertis textbox (name) diganti nama sesusai selera, biar mudah n ga ribet. Misal :
Gaji pokok = GP
Tunjangan = TJ
Gaji Bersih = GB
Potongan = PT
dst
 
#CODING
Public Class Form2


    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Select Case ComboBox1.SelectedItem
            Case "P001"
                NAMA.Text = "IKA"
            Case "P002"
                NAMA.Text = "FITRIA"
            Case "P003"
                NAMA.Text = "NINGRUM"
            Case "P004"
                NAMA.Text = "JOKO"
            Case Else
                NAMA.Text = "WIHARDI"

        End Select
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        Select Case ComboBox2.SelectedItem

            Case "OPERATOR"
                GP.Text = 3000000
                TJ.Text = 1 / 100 * Val(GP.Text)
            Case "STAFF"
                GP.Text = 4000000
                TJ.Text = 10 / 100 * Val(GP.Text)
            Case Else
                GP.Text = 6000000
                TJ.Text = 10 / 100 * Val(GP.Text)
        End Select
        JAM.Focus()
    End Sub

    Private Sub JAM_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles JAM.KeyPress
        If Asc(e.KeyChar) = 13 Then
            LM.Text = Val(JAM.Text) * 15000

            Dim TOTALGAJI As Integer
            TOTALGAJI = Val(GP.Text) + Val(TJ.Text) + Val(LM.Text)

            If TOTALGAJI >= 5000000 Then
                PPH.Text = 0.05 * TOTALGAJI
                KOP.Text = 0.01 * TOTALGAJI
            Else
                PPH.Text = 0.02 * TOTALGAJI
                KOP.Text = 0.01 * TOTALGAJI
            End If
            GB.Text = TOTALGAJI - (Val(PPH.Text) + Val(KOP.Text))
            MsgBox("GAJI BERSIH " & NAMA.Text & " Rp. " & GB.Text)
            GB.Focus()
        End If
    End Sub

    Private Sub JAM_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JAM.TextChanged

    End Sub
End Class



Penjualan toko ribet

*note
pada propertis textbox (name) diganti nama sesusai selera, biar mudah n ga ribet. Misal :
Textbox1 : NAMA
Textbox2 : HARGA
Textbox3 : BELI, dll

#coding
Public Class Form6

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Select Case ComboBox1.SelectedIndex
            Case 0
                NAMA.Text = "BUKU"
                HARGA.Text = 7000
            Case 1
                NAMA.Text = "PULPEN"
                HARGA.Text = 5000
            Case 2
                NAMA.Text = "PENSIL"
                HARGA.Text = 3000
            Case 3
                NAMA.Text = "PENGHAPUS"
                HARGA.Text = 2500
        End Select
        BELI.Focus()
    End Sub

    Private Sub BELI_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BELI.TextChanged
        TOTAL.Text = Val(HARGA.Text) * Val(BELI.Text)
        If BELI.Text >= 10 Then
            DISKON.Text = 0.1 * TOTAL.Text
        Else
            DISKON.Text = 0
        End If
    End Sub

  
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        KEMBALI.Text = Val(BAYAR.Text) - ((TOTAL.Text) - Val(DISKON.Text))
        MsgBox("Kembalian Anda Rp. " & KEMBALI.Text)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ComboBox1.Text = "--pilih--"
        NAMA.Clear()
        HARGA.Clear()
        BELI.Text = 0
        TOTAL.Clear()
        DISKON.Clear()
        BAYAR.Clear()
        KEMBALI.Clear()
    End Sub

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



Penjualan Buah


#coding

Public Class Form5

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Select Case ComboBox1.SelectedItem
            Case "APEL"
                TextBox1.Text = 25000
            Case "JERUK"
                TextBox1.Text = 15000
            Case "MANGGA"
                TextBox1.Text = 10000
            Case "MELON"
                TextBox1.Text = 11000
            Case Else
                TextBox1.Text = 35000
        End Select
        TextBox2.Focus()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ComboBox1.Text = "--pilih--"
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        ComboBox1.Focus()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        MessageBox.Show("yakin ni ga mau nambah", "warninggg!!!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)
        Close()

        End
    End Sub
End Class


Program Penggajian Karyawan



*note
pada propertis textbox (name) diganti nama sesusai selera, biar mudah n ga ribet. Misal :
NAMA =NAMA
KODE JABATAN = KODE
dll


#coding



Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Select KODE.Text
            Case "J01"
                JABATAN.Text = "OPERATOR"
                GAPOK.Text = 2000000
                TUNJANGAN.Text = 0.1 * Val(GAPOK.Text)
            Case "J02"
                JABATAN.Text = "STAFF"
                GAPOK.Text = 3000000
                TUNJANGAN.Text = 0.1 * Val(GAPOK.Text)
            Case Else
                JABATAN.Text = "MANAGER"
                GAPOK.Text = 5000000
                TUNJANGAN.Text = 0.1 * Val(GAPOK.Text)
        End Select


    End Sub

    Private Sub HADIR_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles HADIR.KeyPress
        If Asc(e.KeyChar) = 13 Then
            JUMHADIR.Text = Val(HADIR.Text) * 5000
            End If
    End Sub

    Private Sub LEMBUR_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles LEMBUR.KeyPress
        If Asc(e.KeyChar) = 13 Then
            JUMLEMBUR.Text = Val(LEMBUR.Text) * 7500

        Dim TOTALGAJI As Integer
            TOTALGAJI = Val(GAPOK.Text) + Val(TUNJANGAN.Text) + Val(JUMHADIR.Text) + Val(JUMLEMBUR.Text)

            PAJAK.Text = 0.025 * TOTALGAJI
            KOPERASI.Text = 0.02 * TOTALGAJI
            TOTAL.Text = Val(TOTALGAJI) - Val(PAJAK.Text) - Val(KOPERASI.Text)
            MsgBox("TOTAL GAJI YANG KAMU TERIMA Rp " & TOTAL.Text)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        MessageBox.Show("YAKIN NI MAU KELUAR", "WARNING!!!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)
        Close()

    End Sub
End Class
 


 

Kalkulator sederhana



 #coding
 Public Class Form1

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
    End Sub


Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text) / 100
    End Sub




    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        TextBox1.Text = ""
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox1.Focus()
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        MessageBox.Show("yakin ni mau keluar", "GAWAT", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)
        Close()
    End Sub

End Class





label 2



#coding





Public Class Form2

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        Label2.ForeColor = Color.Red
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label2.Text = TextBox1.Text
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        Label2.ForeColor = Color.Yellow
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        Label2.ForeColor = Color.Green
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        Label2.Font = New Font("arial", Label2.Font.Size, Label2.Font.Style Xor FontStyle.Bold)
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        Label2.Font = New Font("arial", Label2.Font.Size, Label2.Font.Style Xor FontStyle.Italic)
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        Label2.Font = New Font("arial", Label2.Font.Size, Label2.Font.Style Xor FontStyle.Underline)
    End Sub
End Class





Label 3







#coding


Public Class Form3

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Add(ComboBox1.Text)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ListBox1.Items.Remove(ListBox1.Text)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ListBox1.Items.Clear()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        MessageBox.Show("apakah anda yakin mau keluar", "DANGGER", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)
        Close()
    End Sub
End Class

0 komentar :

Posting Komentar