Program Visual Basic Pemakaian Listview Penggajian Karyawan

Pemakaian Listview pada visual basic 6.0 sangat membantu untuk meletakkan beberapa data ke dalam suatu tempat pada program sebelumnya sudah pernah di bahas tentang menggunakan listview pada visual basic 6.

Pada program berikut ini akan diulas kembali untuk kasus yang hampir sama yaitu penggajian karyawan.

Silahkan design form Program Visual Basic Pemakaian Listview Penggajian Karyawan berikut ini .



Untuk perintah ikutin instruksi berikut .

Paling atas Code Program ketikkan perintah berikut ini :
Dim lst As ListItem

Double click Combo NIK rubah event menjadi Click
Private Sub NIK_Click()
    Select Case NIK.Text
    Case "001": Nama.Text = "Oncom"
    Case "002": Nama.Text = "Udin"
    Case "003": Nama.Text = "Ujang"
    End Select
End Sub

Double click Combo Status rubah event menjadi Click
Private Sub Status_Click()
    Select Case Status.Text
    Case "Menikah": TunjKeluarga.Text = 0.15 * Gaji.Text
    Case "Tidak Menikah": TunjKeluarga.Text = 0
    End Select
    Total.Text = Val(Gaji.Text) + Val(TunjKeluarga.Text) - Val(Pajak.Text)
End Sub

Double Click Form 
Private Sub Form_Load()
    NIK.AddItem "001"
    NIK.AddItem "002"
    NIK.AddItem "003"
    Jabatan.AddItem "Mandor"
    Jabatan.AddItem "Kepala Bagian"
    Jabatan.AddItem "Staf"
    Status.AddItem "Menikah"
    Status.AddItem "Tidak Menikah"
    Call cmdBaru_Click
   
    Listview1.ColumnHeaders.Add , , "NIK", 1000
    Listview1.ColumnHeaders.Add , , "Nama", 3000
    Listview1.ColumnHeaders.Add , , "Jabatan", 1500
    Listview1.ColumnHeaders.Add , , "Gaji", 1000
    Listview1.ColumnHeaders.Add , , "Status", 1000
    Listview1.ColumnHeaders.Add , , "Tunj. Keluarga", 1500
    Listview1.ColumnHeaders.Add , , "Pajak", 1000
    Listview1.ColumnHeaders.Add , , "Total Gaji", 1500
    Listview1.GridLines = True
    Listview1.FullRowSelect = True
    Listview1.View = lvwReport
End Sub

Double Click Combo Jabatan rubah event menjadi Click
Private Sub Jabatan_Click()
    Select Case Jabatan.Text
    Case "Mandor": Gaji.Text = 1750000
    Case "Kepala Bagian": Gaji.Text = 2500000
    Case "Staf": Gaji.Text = 1250000
    End Select
    Pajak.Text = 0.15 * Gaji.Text
End Sub

Double Click Command Baru
Private Sub cmdBaru_Click()
    NIK.Text = ""
    Nama.Text = ""
    Status.Text = ""
    Jabatan.Text = ""
    Pajak.Text = ""
    Total.Text = ""
    Gaji.Text = ""
    TunjKeluarga.Text = ""
End Sub

Double Click Command Proses
Private Sub CmdProses_Click()
    Set lst = Listview1.ListItems.Add(, , NIK.Text)
    lst.SubItems(1) = Nama.Text
    lst.SubItems(2) = Jabatan.Text
    lst.SubItems(3) = Gaji.Text
    lst.SubItems(4) = Status.Text
    lst.SubItems(5) = TunjKeluarga.Text
    lst.SubItems(6) = Pajak.Text
    lst.SubItems(7) = Total.Text
    Call cmdBaru_Click
End Sub

Double Click Command Keluar
Private Sub CmdKeluar_Click()
    Unload Me
End Sub

Sehingga keseluruhan program dapat terlihat seperti berikut ini :

Dim lst As ListItem

Private Sub cmdBaru_Click()
    NIK.Text = ""
    Nama.Text = ""
    Status.Text = ""
    Jabatan.Text = ""
    Pajak.Text = ""
    Total.Text = ""
    Gaji.Text = ""
    TunjKeluarga.Text = ""
End Sub

Private Sub CmdKeluar_Click()
    Unload Me
End Sub

Private Sub CmdProses_Click()
    Set lst = Listview1.ListItems.Add(, , NIK.Text)
    lst.SubItems(1) = Nama.Text
    lst.SubItems(2) = Jabatan.Text
    lst.SubItems(3) = Gaji.Text
    lst.SubItems(4) = Status.Text
    lst.SubItems(5) = TunjKeluarga.Text
    lst.SubItems(6) = Pajak.Text
    lst.SubItems(7) = Total.Text
    Call cmdBaru_Click
End Sub

Private Sub Form_Load()
    NIK.AddItem "001"
    NIK.AddItem "002"
    NIK.AddItem "003"
    Jabatan.AddItem "Mandor"
    Jabatan.AddItem "Kepala Bagian"
    Jabatan.AddItem "Staf"
    Status.AddItem "Menikah"
    Status.AddItem "Tidak Menikah"
    Call cmdBaru_Click
   
    Listview1.ColumnHeaders.Add , , "NIK", 1000
    Listview1.ColumnHeaders.Add , , "Nama", 3000
    Listview1.ColumnHeaders.Add , , "Jabatan", 1500
    Listview1.ColumnHeaders.Add , , "Gaji", 1000
    Listview1.ColumnHeaders.Add , , "Status", 1000
    Listview1.ColumnHeaders.Add , , "Tunj. Keluarga", 1500
    Listview1.ColumnHeaders.Add , , "Pajak", 1000
    Listview1.ColumnHeaders.Add , , "Total Gaji", 1500
    Listview1.GridLines = True
    Listview1.FullRowSelect = True
    Listview1.View = lvwReport
End Sub

Private Sub Jabatan_Click()
    Select Case Jabatan.Text
    Case "Mandor": Gaji.Text = 1750000
    Case "Kepala Bagian": Gaji.Text = 2500000
    Case "Staf": Gaji.Text = 1250000
    End Select
    Pajak.Text = 0.15 * Gaji.Text
End Sub

Private Sub NIK_Click()
    Select Case NIK.Text
    Case "001": Nama.Text = "Oncom"
    Case "002": Nama.Text = "Udin"
    Case "003": Nama.Text = "Ujang"
    End Select
End Sub

Private Sub Status_Click()
    Select Case Status.Text
    Case "Menikah": TunjKeluarga.Text = 0.15 * Gaji.Text
    Case "Tidak Menikah": TunjKeluarga.Text = 0
    End Select
    Total.Text = Val(Gaji.Text) + Val(TunjKeluarga.Text) - Val(Pajak.Text)
End Sub

Untuk menjalankan program silahkan Tekan F5. Sehingga hasil program seperti berikut ini.



 Selamat belajar yaa



Program Visual Basic Mencari Jumlah Huruf Hidup

Saya yakin anda pasti tahu huruf hidup bukan? Yap, A, I, U, E, O.  Program berikut ini untuk mencari jumlah rekapitulasi huruf hidup tersebut, baik huruf besar maupun huruf kecil.


Program Visual Basic Mencari Jumlah Huruf Hidup

Silahkan design program visual basic mencari jumlah huruf hidup berikut ini :



Berikut listing program visual basic mencari jumlah huruf hidup.

Private Sub cmduraikan_Click()
    Dim xa As Byte
    Dim xi As Byte
    Dim xu As Byte
    Dim xe As Byte
    Dim xo As Byte
    xa = 0
    xi = 0
    xu = 0
    xe = 0
    xo = 0
    For i = 1 To Len(Kalimat.Text)
        x = Mid(Kalimat.Text, i, 1)
        If x = "a" Or x = "A" Then
            xa = xa + 1
        ElseIf x = "i" Or x = "I" Then
            xi = xi + 1
        ElseIf x = "u" Or x = "U" Then
            xu = xu + 1
        ElseIf x = "e" Or x = "E" Then
            xe = xe + 1
        ElseIf x = "o" Or x = "O" Then
            xo = xo + 1
        End If
    Next i
    jmlA.Text = xa
    jmlI.Text = xi
    jmlU.Text = xu
    jmlE.Text = xe
    jmlO.Text = xo
End Sub


Mau tahu hasilnya?

lihat saja gambar program visual basic mencari jumlah huruf hidup


Menggunakan Listview Pada Visual Basic 6

Untuk memasukkan data ke dalam listview ternyata sangat mudah, lihat saja programnya berikut ini :
Menggunakan Listview Pada Visual Basic 6

Design Form menggunakan listview pada Visual Basic 6


Listing program Form menggunakan listview pada Visual Basic 6
Dim lst As ListItem

Private Sub cmdbersihkan_Click()
    ListView1.ListItems.Clear
End Sub

Private Sub cmdhapus_Click()
    NIK.Text = ""
    Nama.Text = ""
    Gaji.Text = ""
    NIK.SetFocus
End Sub

Private Sub cmdhapuspilih_Click()
    ListView1.ListItems.Remove ListView1.SelectedItem.Index
End Sub

Private Sub cmdsimpan_Click()
    Set lst = ListView1.ListItems.Add(, , NIK.Text)
    lst.SubItems(1) = Nama.Text
    lst.SubItems(2) = Gaji.Text
End Sub

Private Sub Form_Activate()
    cmdhapus_Click
End Sub

Private Sub Form_Load()
    NIK.AddItem "K1011"
    NIK.AddItem "K2012"
    NIK.AddItem "K2021"
    NIK.AddItem "K1022"
   
    ' Untuk membuat listview
    ListView1.ColumnHeaders.Add , , "NIK", 1000
    ListView1.ColumnHeaders.Add , , "Nama", 3000
    ListView1.ColumnHeaders.Add , , "Gaji", 1000
    ListView1.GridLines = True
    ListView1.FullRowSelect = True
    ListView1.View = lvwReport
End Sub

Private Sub NIK_Click()
    Select Case NIK
    Case "K1011": Nama.Text = "Dian"
    Case "K2012": Nama.Text = "Susi"
    Case "K2021": Nama.Text = "Arista"
    Case "K1022": Nama.Text = "Aldyan"
    End Select
End Sub

Berikut hasil menggunakan listview pada Visual Basic 6

Menggunakan Listview Pada Visual Basic 6


Demikian program menggunakan listview pada Visual Basic , happy programming

Simulasi Konversi Biner Ke Desimal Menggunakan Visual Basic

Program berikut ini untuk melakukan simulasi konversi bilangan Biner ke Desimal.


Desiglah form simulasi konversi biner ke Desimal berikut ini :

Simulasi Konversi Biner Ke Desimal Menggunakan Visual Basic










Berikut programnya

Function pangkat(nilai As Byte, pang As Integer) As Double
    pangkat = 0
    Dim xhasil As Double
    xhasil = 1
    For i = 1 To pang
        xhasil = xhasil * nilai
    Next i
    pangkat = xhasil
End Function

Sub Pisahkan()
    If Biner.Text = "" Then Exit Sub
    For i = 0 To 7
        Bin(i).Text = ""
        Des(i).Text = ""
    Next i
    For i = 0 To Len(Biner.Text) - 1
       
        Bin(i).Text = Mid(Biner.Text, Len(Biner.Text) - i, 1)
    Next i
End Sub

Private Sub Bin_Change(Index As Integer)
    Dim xdes As Double
    If Bin(Index).Text = "" Then Exit Sub
    If Bin(Index).Text <> "0" Then
        Des(Index).Text = pangkat(2, Val(Index))
    Else
        Des(Index).Text = 0
    End If
   
    xdes = 0
    For j = 0 To 7
        xdes = xdes + Val(Des(j).Text)
    Next j
    Desimal.Text = xdes
End Sub

Private Sub Biner_Change()
    Call Pisahkan
End Sub

Private Sub Form_Load()
    Dim ctrl As Control
    Dim txtControl As TextBox
    Dim cmbControl As ComboBox
    For Each ctrl In Form1.Controls
        If TypeOf ctrl Is TextBox Then
                ctrl.Text = ""
        End If
    Next
End Sub


Berikut hasil program simulasi konversi biner ke desimal

Simulasi Konversi Biner Ke Desimal Menggunakan Visual Basic










Terima kasih telah membaca artikel Simulasi Konversi Biner ke Desimal menggunakan Visual Basic.

Program Visual Basic Membuat Puzzle 3 x 3

Design form seperti berikut ini :

Program Visual Basic Membuat Puzzle 3 x 3












Berikut merupakan program untuk permainan puzzle tersebut.

Private Sub cek()
    If (Command1.Caption = "1" And Command2.Caption = "2" And Command3.Caption = "3" And Command4.Caption = "4") Then
        If (Command5.Caption = "5" And Command6.Caption = "6" And Command7.Caption = "7") Then
            If (Command8.Caption = "8") Then
                MsgBox ("Selesai")
            End If
        End If
    End If
End Sub
   
Private Sub Command1_Click()
        If Command2.Visible = False Then
            Command2.Visible = True
            Command1.Visible = False
            Command2.Caption = Command1.Caption
        ElseIf Command4.Visible = False Then
            Command4.Visible = True
            Command1.Visible = False
            Command4.Caption = Command1.Caption
        End If
        Call cek
End Sub

Private Sub Command2_Click()
        If Command1.Visible = False Then
            Command1.Visible = True
            Command2.Visible = False
            Command1.Caption = Command2.Caption
        ElseIf Command3.Visible = False Then
            Command3.Visible = True
            Command2.Visible = False
            Command3.Caption = Command2.Caption
        ElseIf Command5.Visible = False Then
            Command5.Visible = True
            Command2.Visible = False
            Command5.Caption = Command2.Caption
        End If
        Call cek
End Sub

Private Sub Command3_Click()
        If Command2.Visible = False Then
            Command2.Visible = True
            Command3.Visible = False
            Command2.Caption = Command3.Caption
        ElseIf Command6.Visible = False Then
            Command6.Visible = True
            Command3.Visible = False
            Command6.Caption = Command3.Caption
        End If
        Call cek
End Sub

Private Sub Command4_Click()
        If Command1.Visible = False Then
            Command1.Visible = True
            Command4.Visible = False
            Command1.Caption = Command4.Caption
        ElseIf Command5.Visible = False Then
            Command5.Visible = True
            Command4.Visible = False
            Command5.Caption = Command4.Caption
        ElseIf Command7.Visible = False Then
            Command7.Visible = True
            Command4.Visible = False
            Command7.Caption = Command4.Caption
        End If
        Call cek
End Sub

Private Sub Command5_Click()
        If Command2.Visible = False Then
            Command2.Visible = True
            Command5.Visible = False
            Command2.Caption = Command5.Caption
        ElseIf Command4.Visible = False Then
            Command4.Visible = True
            Command5.Visible = False
            Command4.Caption = Command5.Caption
        ElseIf Command6.Visible = False Then
            Command6.Visible = True
            Command5.Visible = False
            Command6.Caption = Command5.Caption
        ElseIf Command8.Visible = False Then
            Command8.Visible = True
            Command5.Visible = False
            Command8.Caption = Command5.Caption
        End If
        Call cek
End Sub

Private Sub Command6_Click()
        If Command3.Visible = False Then
            Command3.Visible = True
            Command6.Visible = False
            Command3.Caption = Command6.Caption
        ElseIf Command9.Visible = False Then
            Command9.Visible = True
            Command6.Visible = False
            Command9.Caption = Command6.Caption
        ElseIf Command5.Visible = False Then
            Command5.Visible = True
            Command6.Visible = False
            Command5.Caption = Command6.Caption
        End If
        Call cek
End Sub

Private Sub Command7_Click()
        If Command8.Visible = False Then
            Command8.Visible = True
            Command7.Visible = False
            Command8.Caption = Command7.Caption
        ElseIf Command4.Visible = False Then
            Command4.Visible = True
            Command7.Visible = False
            Command4.Caption = Command7.Caption
        End If
        Call cek
End Sub

Private Sub Command8_Click()
        If Command7.Visible = False Then
            Command7.Visible = True
            Command8.Visible = False
            Command7.Caption = Command8.Caption
        ElseIf Command9.Visible = False Then
            Command9.Visible = True
            Command8.Visible = False
            Command9.Caption = Command8.Caption
        ElseIf Command5.Visible = False Then
            Command5.Visible = True
            Command8.Visible = False
            Command5.Caption = Command8.Caption
        End If
        Call cek
End Sub

Private Sub Command9_Click()
        If Command6.Visible = False Then
            Command6.Visible = True
            Command9.Visible = False
            Command6.Caption = Command9.Caption
        ElseIf Command8.Visible = False Then
            Command8.Visible = True
            Command9.Visible = False
            Command8.Caption = Command9.Caption
        End If
        Call cek
End Sub

Private Sub Acak()
        Dim a, c, m, i, y As Byte
        Dim x(10) As Byte
       
        For i = 0 To 9
            x(i) = i
        Next i
        a = 4
        c = 1
        m = 9
        x(0) = Rnd(9)
        For i = 1 To 9
            x(i) = (a * x(i - 1) + c) Mod m
            If x(i) = 0 Then
                y = i
            End If
        Next
        Command1.Caption = x(0)
        Command2.Caption = x(1)
        Command3.Caption = x(2)
        Command4.Caption = x(3)
        Command5.Caption = x(4)
        Command6.Caption = x(5)
        Command7.Caption = x(6)
        Command8.Caption = x(7)
        Command9.Caption = x(8)
        If y = 1 Then
            Command2.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 2 Then
            Command3.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 3 Then
            Command4.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 4 Then
            Command5.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 5 Then
            Command6.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 6 Then
            Command7.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 7 Then
            Command8.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 8 Then
            Command9.Caption = Command1.Caption
            Command1.Caption = x(y)
        End If
End Sub

Private Sub Form_Load()
        Acak
End Sub

Demikianlah program visual basic membuat puzzle 3 x 3

Program Calculator Pada Visual Basic

Begitu mudahnya membuat program Calculator pada Visual Basic. Mau tahu programnya, lihat saja perintah di bawah ini :

Designlah form program calculator pada visual basic terlebih dahulu

Program Calculator Pada Visual Basic
















Untuk penamaan komponen lihat tabel di bawah ini :
Textbox1 --> Angka
command button 1 --> btn1
command button 2 --> btn2
command button 3 --> btn3
command button 4 --> btn4
command button 5 --> btn5
command button 6 --> btn6
command button 7 --> btn7
command button 8 --> btn8
command button 9 --> btn9
command button 0 --> btn0
command button + --> btnTambah
command button = --> btnHasil
command button - --> btnKurang
command button +/- --> btnMinus
command button X --> btnKali
command button / --> btnBagi
command button C --> btnC
command button Backspace --> btnback


Adapun listing program calculator pada visual basic dapat dilihat berikut ini :

Dim OPnya As String
Dim a As Double
Dim b As Double
Dim c As Double
Dim bil As String


Function Proseskan(op As String)
    Dim xhasil As Double
    Select Case op
    Case "+": xhasil = a + b
    Case "-": xhasil = a - b
    Case "/": xhasil = a / b
    Case "*": xhasil = a * b
    End Select
    Proseskan = xhasil
End Function

Private Sub btn1_Click()
    If bil <> "0" Or OPnya = "" Then
       bil = bil + "1"
    Else
       bil = "1"
    End If
    Angka = bil
End Sub

Private Sub btn2_Click()
    If bil <> "0" Or OPnya = "" Then
       bil = bil + "2"
    Else
       bil = "2"
    End If
    Angka = bil
End Sub

Private Sub btn3_Click()
    If bil <> "0" Or OPnya = "" Then
       bil = bil + "3"
    Else
       bil = "3"
    End If
    Angka = bil
End Sub

Private Sub btn4_Click()
    If bil <> "0" Or OPnya = "" Then
       bil = bil + "4"
    Else
       bil = "4"
    End If
    Angka = bil
End Sub

Private Sub btn5_Click()
    If bil <> "0" Or OPnya = "" Then
       bil = bil + "5"
    Else
       bil = "5"
    End If
    Angka = bil
End Sub

Private Sub btn6_Click()
    If bil <> "0" Or OPnya = "" Then
       bil = bil + "6"
    Else
       bil = "6"
    End If
    Angka = bil
End Sub

Private Sub btn7_Click()
    If bil <> "0" Or OPnya = "" Then
       bil = bil + "7"
    Else
       bil = "7"
    End If
    Angka = bil
End Sub

Private Sub btn8_Click()
    If bil <> "0" Or OPnya = "" Then
       bil = bil + "8"
    Else
       bil = "8"
    End If
    Angka = bil
End Sub
Private Sub btn9_Click()

    If bil <> "0" Or OPnya = "" Then
       bil = bil + "9"
    Else
       bil = "9"
    End If
    Angka = bil
End Sub
Private Sub btn0_Click()
    If bil <> "0" Or OPnya = "" Then
       bil = bil + "0"
    Else
       bil = "0"
    End If
    Angka = bil
End Sub

Private Sub btnback_Click()
    Dim jml As Byte
    jml = Len(bil)
    If jml > 0 Then
        bil = Left(bil, jml - 1)
        Angka = bil
    End If
End Sub

Private Sub btnbagi_Click()
    If bil <> "" Then
        OPnya = "/"
        If a = 0 Then
            a = CCur(bil)
        Else
            b = CCur(bil)
            a = Proseskan("/")
        End If
        bil = ""
    End If
End Sub

Private Sub btnC_Click()
    a = 0
    b = 0
    c = 0
    bil = ""
    OPnya = ""
    Angka = "0"
End Sub

Private Sub btnhasil_Click()
    b = CCur(bil)
    Angka = Proseskan(OPnya)
    bil = "0"
    a = 0
    b = 0
End Sub

Private Sub btnkali_Click()
    If bil <> "" Then
        OPnya = "*"
        If a = 0 Then
            a = CCur(bil)
        Else
            b = CCur(bil)
            a = Proseskan("*")
        End If
        bil = ""
    End If
End Sub

Private Sub btnkoma_Click()
    If bil <> "" Then
        bil = bil + ","
    Else
        bil = "0"
    End If
    Angka = bil
End Sub

Private Sub btnkurang_Click()
    If bil <> "" Then
        OPnya = "-"
        If a = 0 Then
            a = CCur(bil)
        Else
            b = CCur(bil)
            a = Proseskan("-")
        End If
        bil = ""
    End If
End Sub

Private Sub btnminus_Click()
    bil = CCur(bil) * -1
    Angka = bil
End Sub

Private Sub btntambah_Click()
    If bil <> "" Then
        OPnya = "+"
        If a = 0 Then
            a = CCur(bil)
        Else
            b = CCur(bil)
            a = Proseskan("+")
        End If
        bil = ""
    End If
End Sub

Private Sub Form_Load()
    operatornya = ""
    bil = ""
    a = 0
    b = 0
    c = 0
    Angka = "0"
End Sub

ok ! bagaimana mudah bukan?

Program Teks Berjalan Pada Pascal

Program Teks Berjalan Pada Pascal
Pernah memprogram dengan PASCAL tidak? Banyak yang mengatakan pemrograman ini sulit, namun kalau dipilih pemrograman C itu lebih sulit. hehehe, nah hal ini kembali lagi kepada anda semua.

Oh ya tutorial programming hari ini akan memberikan salah satu contoh program pascal untuk membuat suatu teks berjalan dari kiri ke kanan.

Ketiklan program teks berjalan pada pascal berikut ini :

uses crt ;
var
   kata : string ;
   i    : byte ;
   posisi: byte;
begin
     kata := 'Belajar di Mesran.Net' ;
     i := 1 ;
     clrscr ;
     posisi := 1;
     while not keypressed do
     begin
        gotoxy(i-1, 12) ; write('                                   ') ;
        gotoxy(i, 12) ; write(kata) ;
        if posisi=1 then
           inc(i)
        else
           dec(i) ;
        if i=50 then posisi:=0
        else if i=1 then posisi:=1 ;

        delay(200) ;
     end;
end.


pada bagian gotoxy(i-1, 12) ; write('                                   ') ; memang di berikan spasi kosong pada perintah tersebut bertujuan untuk menghapus tampilan sebelumnya.

nah, bagaimana hasilnya apakah program teks berjalan pada pascal sesuai dengan yang anda harapkan?
Back to Top