Saya membuat form slip gaji dengan menggunakan Microsoft Visual Studio 2012.
Saya akan tampilkan screenshoot serta source code nya yaitu:
1. Add reference pada kolom Project
2. Lalu buat interface dari program tersebut:
3. Kemudian buat base pada Microsoft Excel:
Dan inilah sourcecodenya:
Public Class Form1
Dim excelapp As New Microsoft.Office.Interop.Excel.Application
Dim excelbook As New Microsoft.Office.Interop.Excel.Workbook
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim i As Double
excelbook = excelapp.Workbooks.Open("Z:\diva\gaji.xlsx")
excelapp.Range("A" + CStr(i + 1)).Value = TextBox1.Text
excelapp.Range("B" + CStr(i + 1)).Value = ComboBox1.Text
excelapp.Range("C" + CStr(i + 1)).Value = TextBox2.Text
excelapp.Range("D" + CStr(i + 1)).Value = TextBox3.Text
excelapp.Range("E" + CStr(i + 1)).Value = TextBox4.Text
excelapp.Range("F" + CStr(i + 1)).Value = TextBox5.Text
excelapp.Visible = True
End Sub
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
If ComboBox1.Text = "manajer" Then
TextBox3.Text = "5000000"
End If
If ComboBox1.Text = "asisten manajer" Then
TextBox3.Text = "3500000"
End If
If ComboBox1.Text = "karyawan" Then
TextBox3.Text = "1500000"
End If
If ComboBox1.Text = "office boy" Then
TextBox3.Text = "500000"
End If
End Sub
Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged
If ComboBox1.Text = "manajer" Then
TextBox4.Text = "1500000"
End If
If ComboBox1.Text = "asisten manajer" Then
TextBox3.Text = "1000000"
End If
If ComboBox1.Text = "karyawan" Then
TextBox3.Text = "500000"
End If
If ComboBox1.Text = "office boy" Then
TextBox3.Text = "200000"
End If
End Sub
Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
TextBox5.Text = TextBox2.Text + TextBox3.Text - TextBox4.Text
End Sub
End Class
Terimakasih..

Tidak ada komentar:
Posting Komentar