Uploaded by demonpiw

Tugas aplikasi visual basic

advertisement
TUGAS APLIKASI VISUAL BASIC
Purwo Inggi Wiratam (1955201011)
Tampilan Form Menu Awal
Property
Toolbox
form
Text
(name)
Tugas Aplikasi Visual Basic
MenuAwal
PictureBox
Picturebox1
MenuStrip
Menustrip1
Button
Label
Calculator
btncalculator
Gaji
btngaji
Gambar
btngambar
Silahkan Login Terlebih
Dahulu
lbawal
0
onoof
Kodingan :
Imports System.ComponentModel
Public Class MenuAwal
Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
AboutToolStripMenuItem.Click
MsgBox("Nama : Purwo Inggi Wiratam" + vbCrLf +
"NIM : 1955201011" + vbCrLf +
"WA : 085776244460" + vbCrLf +
"Email : demonpiw@gmail.com", MsgBoxStyle.Information, "Jika Ada Pertanyaan Tentang
Aplikasi Ini")
End Sub
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
ExitToolStripMenuItem.Click
Dim kata1, kata2, kata3, kata4 As String
'kata1 = "Apa anda yakin ingin Keluar ?"
kata2 = "Kenapa Bro?"
kata3 = "Yakin? Seriusan?"
kata4 = "Pemberitahuan"
kata1 = MsgBox(kata3, MsgBoxStyle.YesNo, kata4)
If kata1 = vbYes Then
Me.Close()
Else
MsgBox(kata2, MsgBoxStyle.OkOnly, kata4)
End If
End Sub
Private Sub CalculatorSederhanaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
CalculatorSederhanaToolStripMenuItem.Click
CalculatorSederhana.Show()
End Sub
Private Sub MenuAwal_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
If MsgBox("Anda yakin ingin keluar ?", MsgBoxStyle.Information Or MsgBoxStyle.YesNo,
"Konfirmasi") = MsgBoxResult.Yes Then
e.Cancel = False
Else
e.Cancel = True
End If
End Sub
Private Sub LogInToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles
LogInToolStripMenuItem1.Click
FormLogin.Show()
'LogInToolStripMenuItem1.Enabled = False
'LogOutToolStripMenuItem.Enabled = True
End Sub
Private Sub LogOutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
LogOutToolStripMenuItem.Click
LogInToolStripMenuItem1.Enabled = True
End Sub
Private Sub DataGajiToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
DataGajiToolStripMenuItem.Click
DataGajiKaryawan.Show()
End Sub
Private Sub OpenGambarToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
OpenGambarToolStripMenuItem.Click
GambarUpload.Show()
End Sub
Private Sub onoff_DoubleClick(sender As Object, e As EventArgs) Handles onoff.DoubleClick
If onoff.Text = "0" Then
FormListToolStripMenuItem.Enabled = True
btncalculator.Enabled = True
btngaji.Enabled = True
btngambar.Enabled = True
lbawal.Text = "Selamat Datang"
onoff.Text = "1"
Else
FormListToolStripMenuItem.Enabled = False
btncalculator.Enabled = False
btngaji.Enabled = False
btngambar.Enabled = False
lbawal.Text = "Silahkan Login Terlebih Dahulu"
onoff.Text = "0"
End If
End Sub
Private Sub btngambar_Click(sender As Object, e As EventArgs) Handles btngambar.Click
GambarUpload.Show()
End Sub
Private Sub btngaji_Click(sender As Object, e As EventArgs) Handles btngaji.Click
DataGajiKaryawan.Show()
End Sub
Private Sub btncalculator_Click(sender As Object, e As EventArgs) Handles btncalculator.Click
CalculatorSederhana.Show()
End Sub
End Class
Tampilan Form Data Gaji Karyawan
Property
Toolbox
Text
(name)
Form
Data Gaji Karyawan
DataGajiKaryawan
RadioButton
Laki-Laki
rdmale
Perempuan
rdfemale
Hapus
btnhapus
Ubah
btnubah
Simpan
btnsimpan
Reset
btnreset
Keluar
btnkeluar
Button
Label
Kode Karyawan
Label1
Nama Karyawan
Label2
Jenis Kelamin
Label3
Jabatan
Label4
Gaji Pokok
Label5
lbket
TextBox
tbkode
tbnama
tbgaji
ComboBox
Silahkan Pilih
cbjabatan
Kodingan :
Imports System.ComponentModel
Public Class DataGajiKaryawan
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnubah.Click,
btnhapus.Click
End Sub
Private Sub DataGajiKaryawan_Load(sender As Object, e As EventArgs) Handles Me.Load
cbjabatan.Items.Add("Direksi")
cbjabatan.Items.Add("Kepala Bagian")
cbjabatan.Items.Add("Staff")
End Sub
Private Sub cbjabatan_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
cbjabatan.SelectedIndexChanged
If cbjabatan.Text = "Direksi" Then
tbgaji.Text = "8000000"
ElseIf cbjabatan.Text = "Kepala Bagian" Then
tbgaji.Text = "5000000"
Else
tbgaji.Text = "2800000"
End If
End Sub
Private Sub btnkeluar_Click(sender As Object, e As EventArgs) Handles btnkeluar.Click
Me.Close()
End Sub
Private Sub tbkode_LostFocus(sender As Object, e As EventArgs) Handles tbkode.LostFocus
tbkode.Text = tbkode.Text.ToUpper
End Sub
Private Sub btnreset_Click(sender As Object, e As EventArgs) Handles btnreset.Click
tbkode.Text = ""
tbgaji.Text = ""
cbjabatan.Text = "Silahkan Pilih..."
tbnama.Text = ""
tbkode.Focus()
End Sub
Private Sub btnsimpan_Click(sender As Object, e As EventArgs) Handles btnsimpan.Click
MsgBox("Maaf Sedang Maintenance", MsgBoxStyle.OkOnly, "Pemberitahuan")
End Sub
Private Sub cbjabatan_GotFocus(sender As Object, e As EventArgs) Handles cbjabatan.GotFocus
If cbjabatan.Text = "Silahkan Pilih..." Then
cbjabatan.Text = ""
End If
End Sub
Private Sub cbjabatan_LostFocus(sender As Object, e As EventArgs) Handles cbjabatan.LostFocus
If cbjabatan.Text = "Direksi" Then
tbgaji.Text = "8000000"
ElseIf cbjabatan.Text = "Kepala Bagian" Then
tbgaji.Text = "5000000"
ElseIf cbjabatan.Text = "Staff" Then
tbgaji.Text = "2800000"
Else
tbgaji.Text = ""
End If
End Sub
Private Sub rdmale_GotFocus(sender As Object, e As EventArgs) Handles rdmale.GotFocus
rdmale.Checked = True
End Sub
Private Sub rdmale_CheckedChanged(sender As Object, e As EventArgs) Handles
rdmale.CheckedChanged
lbket.Text = "Laki-Laki"
End Sub
Private Sub rdfemale_CheckedChanged(sender As Object, e As EventArgs) Handles
rdfemale.CheckedChanged
lbket.Text = "Perempuan"
End Sub
Private Sub DataGajiKaryawan_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
If MsgBox("Anda yakin ingin keluar ?", MsgBoxStyle.Information Or MsgBoxStyle.YesNo,
"Konfirmasi") = MsgBoxResult.Yes Then
e.Cancel = False
Else
e.Cancel = True
End If
End Sub
End Class
Tampilan Form Calculator Sederhana
Property
Toolbox
Text
(name)
Form
Calculator Sederhana
CalculatorSederhana
Label
Masukan Angka
Label1
Angka Pertama
Label2
Angka Kedua
Label3
Hasil
Label4
*) Angka Di Atas Belum
Diisi
lbwan1
*) Angka Di Atas Belum
Diisi
lbwarn2
+
btntambah
-
btnkurang
X
btnkali
÷
btnbagi
Mod
btnsisa
Reset
btnreset
Close
btnclose
Button
TextBox
tb1
tb2
tbhasil
Kodingan :
Public Class CalculatorSederhana
Public angka1, angka2, hasil As Double
'Public angka1 = tb1.Text
Private Sub btnreset_Click(sender As Object, e As EventArgs) Handles btnreset.Click
tb1.Text = ""
tb2.Text = ""
tbhasil.Text = ""
lbwarn1.Visible = False
lbwarn2.Visible = False
tb1.Focus()
End Sub
Private Sub tb1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles tb1.KeyPress
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack Or
e.KeyChar = ".") Then
e.Handled = True
End If
End Sub
Private Sub tb2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles tb2.KeyPress
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack Or
e.KeyChar = ".") Then
e.Handled = True
End If
End Sub
Private Sub btnclose_Click(sender As Object, e As EventArgs) Handles btnclose.Click
Me.Close()
End Sub
Private Sub tb1_LostFocus(sender As Object, e As EventArgs) Handles tb1.LostFocus
If tb1.Text = "" Then
lbwarn1.Visible = True
ElseIf Not tb1.Text = "" Then
lbwarn1.Visible = False
End If
End Sub
Private Sub btnkurang_Click(sender As Object, e As EventArgs) Handles btnkurang.Click
If tb1.Text = "" Or tb2.Text = "" Then
'My.Computer.Audio.Play("E:\DLL\TUGAS\VisualBasic\File\sound\Wrong-answer-soundeffect.wav")
MsgBox("Angka Tidak Boleh Kosong!", MsgBoxStyle.Exclamation, "Peringatan")
Else
angka1 = tb1.Text
angka2 = tb2.Text
hasil = angka1 - angka2
tbhasil.Text = hasil
lbwarn1.Visible = False
lbwarn2.Visible = False
End If
If tb1.Text = "" Then
tb1.Focus()
ElseIf tb2.Text = "" Then
tb2.Focus()
lbwarn2.Visible = True
End If
End Sub
Private Sub btnkali_Click(sender As Object, e As EventArgs) Handles btnkali.Click
If tb1.Text = "" Or tb2.Text = "" Then
'My.Computer.Audio.Play("E:\DLL\TUGAS\VisualBasic\File\sound\Wrong-answer-soundeffect.wav")
MsgBox("Angka Tidak Boleh Kosong!", MsgBoxStyle.Exclamation, "Peringatan")
Else
angka1 = tb1.Text
angka2 = tb2.Text
hasil = angka1 * angka2
tbhasil.Text = hasil
lbwarn1.Visible = False
lbwarn2.Visible = False
End If
If tb1.Text = "" Then
tb1.Focus()
ElseIf tb2.Text = "" Then
tb2.Focus()
lbwarn2.Visible = True
End If
End Sub
Private Sub btnbagi_Click(sender As Object, e As EventArgs) Handles btnbagi.Click
If tb1.Text = "" Or tb2.Text = "" Then
'My.Computer.Audio.Play("E:\DLL\TUGAS\VisualBasic\File\sound\Wrong-answer-soundeffect.wav")
MsgBox("Angka Tidak Boleh Kosong!", MsgBoxStyle.Exclamation, "Peringatan")
Else
angka1 = tb1.Text
angka2 = tb2.Text
hasil = angka1 / angka2
tbhasil.Text = hasil
lbwarn1.Visible = False
lbwarn2.Visible = False
End If
If tb1.Text = "" Then
tb1.Focus()
ElseIf tb2.Text = "" Then
tb2.Focus()
lbwarn2.Visible = True
End If
End Sub
Private Sub btnsisa_Click(sender As Object, e As EventArgs) Handles btnsisa.Click
If tb1.Text = "" Or tb2.Text = "" Then
'My.Computer.Audio.Play("E:\DLL\TUGAS\VisualBasic\File\sound\Wrong-answer-soundeffect.wav")
MsgBox("Angka Tidak Boleh Kosong!", MsgBoxStyle.Exclamation, "Peringatan")
Else
angka1 = tb1.Text
angka2 = tb2.Text
hasil = angka1 Mod angka2
tbhasil.Text = hasil
lbwarn1.Visible = False
lbwarn2.Visible = False
End If
If tb1.Text = "" Then
tb1.Focus()
ElseIf tb2.Text = "" Then
tb2.Focus()
lbwarn2.Visible = True
End If
End Sub
Private Sub tb2_LostFocus(sender As Object, e As EventArgs) Handles tb2.LostFocus
If tb2.Text = "" Then
lbwarn2.Visible = True
ElseIf Not tb2.Text = "" Then
lbwarn2.Visible = False
End If
End Sub
Private Sub btntambah_Click(sender As Object, e As EventArgs) Handles btntambah.Click
If tb1.Text = "" Or tb2.Text = "" Then
'My.Computer.Audio.Play("E:\DLL\TUGAS\VisualBasic\File\sound\Wrong-answer-soundeffect.wav")
MsgBox("Angka Tidak Boleh Kosong!", MsgBoxStyle.Exclamation, "Peringatan")
Else
angka1 = tb1.Text
angka2 = tb2.Text
hasil = angka1 + angka2
tbhasil.Text = hasil
lbwarn1.Visible = False
lbwarn2.Visible = False
End If
If tb1.Text = "" Then
tb1.Focus()
ElseIf tb2.Text = "" Then
tb2.Focus()
lbwarn2.Visible = True
End If
End Sub
End Class
Tampilan Form Form Login
Property
Toolbox
Text
(name)
Form
Form Login
FormLogin
Label
Username
Label1
Password
Label2
TextBox
tbuser
tbpass
Button
Login
btnlogin
Batal
btnbatal
DateTimePicker
DTP1
CheckBox
cbpass
UseSystemPasswordChar =
True
Kodingan :
Public Class FormLogin
Public user, pass As String
Private Sub btnlogin_Click(sender As Object, e As EventArgs) Handles btnlogin.Click
user = "admin"
pass = "admin" + Me.DTP1.Value.Day.ToString
'If tbpass.Text = user And tbuser.Text = user Then
If tbpass.Text = pass And tbuser.Text = user Then
tbuser.Text = ""
tbpass.Text = ""
MenuAwal.LogOutToolStripMenuItem.Enabled = True
MenuAwal.LogInToolStripMenuItem1.Enabled = False
MenuAwal.btncalculator.Enabled = True
MenuAwal.btngaji.Enabled = True
MenuAwal.btngambar.Enabled = True
Me.Close()
Else
MsgBox("Username atau Password Salah!!!", MsgBoxStyle.Critical, "Wrong")
End If
End Sub
Private Sub cbpass_CheckedChanged(sender As Object, e As EventArgs) Handles
cbpass.CheckedChanged
If cbpass.Checked = True Then
tbpass.UseSystemPasswordChar = False
Else
tbpass.UseSystemPasswordChar = True
End If
End Sub
Private Sub btnbatal_Click(sender As Object, e As EventArgs) Handles btnbatal.Click
Me.Close()
End Sub
Private Sub tbpass_KeyDown(sender As Object, e As KeyEventArgs) Handles tbpass.KeyDown
If Control.IsKeyLocked(Keys.CapsLock) Then
lbcaps.Visible = True
lbcaps.Text = "CAPS LOCK is On"
lbcaps.ForeColor = Color.YellowGreen
Else
lbcaps.Visible = False
End If
End Sub
End Class
Tammpilan Form Gambar Upload
Property
Toolbox
Form
OpenFileDialog
Text
(name)
Gambar Upload
Gambar Upload
OpenFileDialog1
PictureBox
picbox1
TextBox
tb1
Button
Browse
btnbrowse
Kodingan :
Public Class GambarUpload
Private Sub btnbrowse_Click(sender As Object, e As EventArgs) Handles btnbrowse.Click
OpenFileDialog1.Filter = "Picture Files (*.BMP; *.GIF; *.JPG)|*.BMP;*.GIF;*.JPG|Bitmap Files
(*.BMP)|*.BMP|GIF Files (*.GIF)|*.GIF|JPEG Files (*.JPG)|*.JPG|All FIles (*.*)|*.*"
OpenFileDialog1.ShowDialog()
Me.tb1.Text = OpenFileDialog1.FileName
picbox1.ImageLocation = OpenFileDialog1.FileName
If Me.tb1.Text = "" Then
picbox1.ImageLocation = ""
End If
End Sub
End Class
Hasil Running
Download