Jumat, 06 Maret 2020

Thresholding Citra

Citra digital merupakan representasi dari fungsi intensitas cahaya dalam bidang dua dimensi. Berdasarkan jenis warnanya, citra dapat dikelompokkan menjadi tiga jenis yaitu citra RGB, citra grayscale, dan citra biner.

Citra_RGB Citra_Grayscale Citra_Biner

Citra RGB merupakan citra yang tersusun oleh tiga kanal warna yaitu kanal merah, kanal hijau, dan kanal biru. Pada citra RGB 24-bit, masing-masing kanal warna memiliki nilai intensitas piksel dengan kedalaman bit sebesar 8-bit yang artinya memiliki variasi warna sebanyak 2^8 = 256 derajat warna (0 s.d 255). Setiap piksel pada citra RGB memiliki nilai intensitas yang merupakan kombinasi dari nilai R, G, dan B. Variasi warna pada setiap piksel pada citra RGB adalah sebanyak 256 x 256 x 256 = 16.777.216.

Sedangkan citra grayscale merupakan citra yang hanya memiliki satu kanal warna. Pada citra grayscale 8-bit, setiap piksel memiliki nilai intensitas warna yang memiliki variasi sebanyak 2^8 = 256 derajat warna (0 s.d 255). Nilai intensitas pada citra ini merupakan representasi dari derajat keabuan di mana nilai 0 menyatakan warna hitam sempurna dan nilai 255 menyatakan warna putih sempurna. Nilai intensitas antara 0 s.d 255 merupakan warna abu-abu.

Sama seperti citra grayscale, citra biner juga merupakan citra yang hanya memiliki satu kanal warna. Citra biner memiliki kedalaman bit sebesar 1-bit. Nilai intensitas warna pada setiap piksel citra biner dibagi menjadi 2^1 = 2 warna yaitu warna hitam yang dinyatakan oleh nilai 0 dan warna putih yang dinyatakan oleh nilai 1.
Materi lebih lanjut mengenai definisi dan jenis citra digital dapat dilihat pada laman berikut ini: Pengolahan Citra Digital
Berikut ini merupakan tutorial cara membuat citra berwarna (RGB) menjadi hitam putih (biner) menggunakan Graphical User Interface  (GUI) MATLAB

Langkah-langkahnya yaitu:

1. Membuka aplikasi software Matlab


2. Membuka GUIDE Matlab dengan cara mengetik “guide” pada command window dan tekan enter, sehingga muncul tampilan seperti pada gambar di bawah ini


atau klik menu New >> Graphical User Interface seperti yang ditunjukkan pada gambar berikut

 3. Klik “Ok” pada GUIDE Quick Start >> Create New GUI >> Blank GUI (default)

sehingga akan muncul tampilan GUIDE Matlab seperti pada gambar berikut

 4. Untuk menampilkan nama palet komponen, klik File >> Preferences

 kemudian beri tanda centang (√) pada menu Show names in component palette lalu klik “Ok”
  

 sehingga akan muncul tampilan seperti pada gambar di bawah ini

5. Buatlah rancangan GUI MATLAB yang terdiri dari 2 axes, 3 pushbutton, 1 slider, dan 1 edit text seperti tampak pada gambar di bawah ini

6. Editlah property masing-masing komponen dengan cara meng-double klik setiap komponen lalu mengganti propertynya sesuai dengan tabel berikut
No Nama Komponen Property Nilai
1 Pushbutton String Open Image
Tag pushbutton1
2 Pushbutton String Grayscale
Tag pushbutton2
3 Pushbutton String Save
Tag pushbutton3
4 Slider min 0
max 255
tag slider1
5 Edit Text String <kosongkan>
6 Axes XTick <kosongkan>
YTick <kosongkan>
ZTick <kosongkan>
7 Axes XTick <kosongkan>
YTick <kosongkan>
ZTick <kosongkan>

sehingga tampilan GUI tampak pada gambar berikut:

7. Listing Program untuk pusbutton1 (tombol buka citra) adalah

 % --- Executes on button press in pushbutton1.
 function pushbutton1_Callback(hObject, eventdata, handles)
 % hObject    handle to pushbutton1 (see GCBO)
 % eventdata  reserved - to be defined in a future version of MATLAB
 % handles    structure with handles and user data (see GUIDATA)
 [name_file1,name_path1] = uigetfile( ...
    {'*.bmp;*.jpg;*.tif','Files of type (*.bmp,*.jpg,*.tif)';
    '*.bmp','File Bitmap (*.bmp)';...
    '*.jpg','File jpeg (*.jpg)';
    '*.tif','File Tif (*.tif)';
    '*.*','All Files (*.*)'},...
    'Open Image');

 if ~isequal(name_file1,0)
    handles.data1 = imread(fullfile(name_path1,name_file1));
    guidata(hObject,handles);
    axes(handles.axes1);
    imshow(handles.data1);
 else
    return;
 end
 
Listing Program untuk pusbutton2 (konversi citra RGB menjadi grayscale)
 
 % --- Executes on button press in pushbutton2.
 function pushbutton2_Callback(hObject, eventdata, handles)
 % hObject    handle to pushbutton2 (see GCBO)
 % eventdata  reserved - to be defined in a future version of MATLAB
 % handles    structure with handles and user data (see GUIDATA)
 image1 = handles.data1;
 gray = rgb2gray(image1);
 axes(handles.axes2);
 imshow(gray);
 handles.data2 = gray;
 guidata(hObject,handles);
 
Listing Program untuk slider1 (konversi citra grayscale menjadi biner)
 
 % --- Executes on slider movement.
 function slider1_Callback(hObject, eventdata, handles)
 % hObject    handle to slider1 (see GCBO)
 % eventdata  reserved - to be defined in a future version of MATLAB
 % handles    structure with handles and user data (see GUIDATA)

 % Hints: get(hObject,'Value') returns position of slider
 % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
 gray = handles.data2;
 value = get(handles.slider1,'value');
 thresh = imcomplement(im2bw(gray,value/255));
 axes(handles.axes2);
 imshow(thresh);
 handles.data3 = thresh;
 guidata(hObject,handles);
 set(handles.edit1,'String',value)
 
Listing Program untuk pushbutton3 (menyimpan citra biner hasil konversi) 
  
 % --- Executes on button press in pushbutton3.
 function pushbutton3_Callback(hObject, eventdata, handles)
 % hObject    handle to pushbutton3 (see GCBO)
 % eventdata  reserved - to be defined in a future version of MATLAB
 % handles    structure with handles and user data (see GUIDATA)
 thresh = handles.data3;
 [name_file_save,path_save] = uiputfile( ...
    {'*.bmp','File Bitmap (*.bmp)';...
    '*.jpg','File jpeg (*.jpg)';
    '*.tif','File Tif (*.tif)';
    '*.*','All Files (*.*)'},...
    'Save Image');
 if ~isequal(name_file_save,0)
    imwrite(thresh,fullfile(path_save,name_file_save));
 else
    return
 end

8. Ketika di Run maka tampilan GUI akan tampak seperti pada gambar di bawah ini
 
9. Klik Open Image, pilih gambar yang ingin diproses 

10. Klik Grayscale

11. Geser nilai Slider

12. Citra biner yang terbentuk dapat disimpan dengan cara meng-klik tombol Save Image 

Selasa, 12 Desember 2017

Tugas 3.7 Pt.Pulang petang Setiap Hari oleh mahasiswa STMIK Pringsewu

Tugas 3.7 Pt.Pulang petang Setiap Hari


Berikut Source Codenya:

Private Sub cmdbatal_Click()
txtnama.SetFocus
txtnik.Text = ""
txtgolongan.Text = ""
txtkode.Text = ""
txtstatus.Text = ""
txttahun.Text = ""
txtjabatan.Text = ""
txtbagian.Text = ""
txtgaji.Text = ""
txttunjangan.Text = ""
txttotal.Text = ""
txtnama.Text = ""
End Sub

Private Sub cmdlagi_Click()
txtnama.SetFocus
txtnik.Text = ""
txtgolongan.Text = ""
txtkode.Text = ""
txtstatus.Text = ""
txttahun.Text = ""
txtjabatan.Text = ""
txtbagian.Text = ""
txtgaji.Text = ""
txttunjangan.Text = ""
txttotal.Text = ""
txtnama.Text = ""
End Sub

Private Sub cmdkeluar_Click()
End
End Sub

Private Sub cmdproses_Click()
Dim x As String
txtgolongan.Text = Mid(txtnik.Text, 5, 1)
txtkode.Text = Mid(txtnik.Text, 7, 1)
txttahun.Text = Left(txtnik.Text, 4)

x = Mid(txtnik.Text, 7, 1)
If x = "S" Or x = "s" Then
txtstatus.Text = "Single"

ElseIf x = "M" Or x = "m" Then
txtstatus.Text = "Menikah"

ElseIf x = "J" Or x = "j" Then
txtstatus.Text = "Janda"

ElseIf x = "D" Or x = "d" Then
txtstatus.Text = "Duda"

End If

x = Mid(txtnik.Text, 5, 1)
If x = "A" Or x = "a" Then
txtjabatan.Text = "Manager"
txtgaji.Text = "4000000"
txttunjangan.Text = "1025000"

ElseIf x = "B" Or x = "b" Then
txtjabatan.Text = "Ka.Seksi"
txtgaji.Text = "3500000"
txttunjangan.Text = "975000"

ElseIf x = "C" Or x = "c" Then
txtjabatan.Text = "Staff"
txtgaji.Text = "3000000"
txttunjangan.Text = "925000"

End If

x = Right(txtnik.Text, 3)
If x = "KEU" Then
txtbagian.Text = "Accounting"

ElseIf x = "ADM" Then
txtbagian.Text = "Administrasi"

ElseIf x = "SDM" Then
txtbagian.Text = "General Affair"

ElseIf x = "EDP" Then
txtbagian.Text = "IT Unit"

ElseIf x = "SPM" Then
txtbagian.Text = "Security"
End If

txttotal.Text = Val(txtgaji.Text) + Val(txttunjangan.Text)
End Sub

Private Sub txtnama_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtnik.SetFocus
End If
End Sub

Tugas 3.6 Data Buku Stimik Pringsewu

Tugas 3.6 Data Buku Stimik Pringsewu


Berikut Source Codenya:

Private Sub Cmdbatal_Click()
kosong
End Sub

Private Sub cmdlagi_Click()
kosong
End Sub

Private Sub cmdkeluar_Click()
Unload Me
End Sub

Public Sub kosong()
txtkode.SetFocus
txtkode.Text = ""
txtjudul.Text = ""
txtpengarang.Text = ""
txttahun.Text = ""
txtpenerbit.Text = ""
txtharga.Text = ""
End Sub

Private Sub cmdproses_Click()
Dim K As String
K = Left(txtkode.Text, 3)
If K = "SIM" Or K = "sim" Then
txtjudul = "Sistem Informasi Manajemen"
txtpengarang = "Fadiya Ulfa"
txtharga = "75900"
ElseIf K = "EDP" Or K = "edp" Then
txtjudul = "Elektronik Data Processing"
txtpengarang = "Nurul Agustina"
txtharga = "62000"
ElseIf K = "MNJ" Or K = "mnj" Then
txtjudul = "Manajemen”"
txtpengarang = "Rian Hidayat"
txtharga = "42000"
ElseIf K = "CDR" Or K = "cdr" Then
txtjudul = "Corel Draw"
txtpengarang = "Siti Nur Khotimah"
txtharga = "53000"
ElseIf K = "RPL" Or K = "rpl" Then
txtjudul = "Rekayasa Perangkat Lunak"
txtpengarang = "Winda Erlianti"
txtharga = "83000"
End If
K = Right(txtkode.Text, 1)
If K = "A" Or K = "a" Then
txtpenerbit = "Andi Offset Yogyakarta"
ElseIf K = "I" Or K = "i" Then
txtpenerbit = "Indah Surabaya"
ElseIf K = "S" Or K = "s" Then
txtpenerbit = "Salemba Empat"
ElseIf K = "E" Or K = "e" Then
txtpenerbit = "Elek Media Komputindo"
ElseIf K = "M" Or K = "m" Then
txtpenerbit = "Maxicom"
End If
txttahun.Text = "20" & Mid(txtkode.Text, 5, 2)
End Sub

Private Sub Form_Activate()
txtkode.SetFocus
txtkode.Text = ""
txtjudul.Text = ""
txtpengarang.Text = ""
txttahun.Text = ""
txtpenerbit.Text = ""
txtharga.Text = ""
End Sub

Private Sub txtkode_KeyPress(KeyAscii As Integer)
Dim K As String
K = Left(txtkode.Text, 3)
If K = "SIM" Or K = "sim" Then
txtjudul = "Sistem Informasi Manajemen"
txtpengarang = "Fadiya Ulfa"
txtharga = "75900"
ElseIf K = "EDP" Or K = "edp" Then
txtjudul = "Elektronik Data Processing"
txtpengarang = "Nurul Agustina"
txtharga = "62000"
ElseIf K = "MNJ" Or K = "mnj" Then
txtjudul = "Manajemen”"
txtpengarang = "Rian Hidayat"
txtharga = "42000"
ElseIf K = "cdr" Or K = "cdr" Then
txtjudul = "Corel Draw"
txtpengarang = "Siti Nur Khotimah"
txtharga = "53000"
ElseIf K = "rpl" Or K = "rpl" Then
txtjudul = "Rekayasa Perangkat Lunak"
txtpengarang = "Winda Erlianti"
txtharga = "83000"
End If
K = Right(txtkode.Text, 1)
If K = "A" Or K = "a" Then
txtpenerbit = "Andi Offset Yogyakarta"
ElseIf K = "I" Or K = "i" Then
txtpenerbit = "Indah Surabaya"
ElseIf K = "S" Or K = "s" Then
txtpenerbit = "Salemba Empat"
ElseIf K = "E" Or K = "e" Then
txtpenerbit = "Elek Media Komputindo"
ElseIf K = "M" Or K = "m" Then
txtpenerbit = "Maxicom"
End If
txttahun.Text = "20" & Mid(txtkode.Text, 5, 2)
End Sub

Tugas 3.5 Penjualan Tiket Kerata Api oleh mahasiswa stmik pringsewu

Tugas 3.5 Penjualan Tiket Kerata Api


Berikut Source Codenya:

Private Sub Form_Activate()
txtkt.SetFocus
End Sub

Private Sub cmdkeluar_Click()
Unload Me
End Sub

Private Sub cmdlagi_Click()
txtkt.SetFocus
txtkt.Text = “”
txtht.Text = “”
txtjk.Text = ""
txtjb.Text = ""
txtjt.Text = ""
txttp.Text = ""
End Sub

Private Sub cmdproses_Click()
Dim kt, jk, jb As String
Dim ht As Currency
kt = Left(txtkt.Text, 3)
If kt = "BIM" Or kt = "bim" Then
ht = "50000"
jk = "BIMA"
jb = "16.00"
ElseIf kt = "EKO" Or kt = "eko" Then
ht = "35000"
jk = "EKONOMI"
jb = "19.00"
ElseIf kt = "MUT" Or kt = "mut" Then
ht = "23000"
jk = "MUTIARA"
jb = "17.00"
ElseIf kt = "SEN" Or kt = "sen" Then
ht = "15000"
jk = "SENJA"
jb = "20.00"
End If
txtht.Text = ht
txtjk.Text = jk
txtjb.Text = jb
txtjt.SetFocus
End Sub

Private Sub txtjt_keypress(keyascii As Integer)
If keyascii = 13 Then
txttp.Text = Val(txtht.Text) * Val(txtjt.Text)
End If
End Sub

Tugas 3.4 Data Buku Stmik Pringsewu

Tugas 3.4 Data Buku Stmik Pringsewu



Berikut Source Codenya:

Private Sub Cmdbatal_Click()
kosong
End Sub

Private Sub cmdlagi_Click()
kosong
End Sub

Private Sub cmdkeluar_Click()
Unload Me
End Sub

Public Sub kosong()
cbokb.SetFocus
cbokb.Text = ""
txtjb.Text = ""
txtpeng.Text = ""
txtt.Text = ""
txtpen.Text = ""
txthar.Text = ""
End Sub

Private Sub Form_Load()
cbokb.AddItem "A-SIM-01"
cbokb.AddItem "I-EDP-02"
cbokb.AddItem "S-MNJ-03"
cbokb.AddItem "E-CDR-04"
cbokb.AddItem "M-RPL-05"
End Sub

Private Sub cmdproses_Click()
Dim re As String
txtt.Text = "20" & Right(cbokb.Text, 2)
re = Mid(cbokb.Text, 3, 3)
If re = "SIM" Then
txtjb.Text = "Sistem Informasi Manajemen"
ElseIf re = "EDP" Then
txtjb.Text = "Elektronik Data Processing"
ElseIf re = "MNJ" Then
txtjb.Text = "Manajemen"
ElseIf re = "CDR" Then
txtjb.Text = "Corel Draw"
ElseIf re = "RPL" Then
txtjb.Text = "Rekayasa Perangkat Lunak"
End If

re = Left(cbokb.Text, 1)
If re = "A" Then
txtpeng.Text = "Yati Nur Oktavia"
txthar.Text = "75900"
txtpen.Text = "Andi Offset Yogyakarta"
ElseIf re = "I" Then
txtpeng.Text = "Imam Tarmizi"
txthar.Text = "620000"
txtpen.Text = "Indah Surabaya"
ElseIf re = "S" Then
txtpeng.Text = "Valentina Mariana adiwinanti"
txthar.Text = "42000"
txtpen.Text = "Salemba Empat"
ElseIf re = "E" Then
txtpeng.Text = "Ryan Suhandi"
txthar.Text = "53000"
txtpen.Text = "Elek Media Komputindo"
ElseIf re = "M" Then
txtpen.Text = "Sinta Umpu Singa"
txthar.Text = "83000"
txtpen.Text = "Maxicom"
End If
txthar.SetFocus
End Sub

Tugas 3.3 Entri Penjualan Laptop Aplle oleh mahasiswa stmik

Tugas 3.3 Entri Penjualan Laptop Aplle


Berikut Source Codenya:

Private Sub Form_Load()
cbokode.AddItem "Apple MC965 Macbook Air"
cbokode.AddItem "Apple MC966 Macbook Air"
cbokode.AddItem "Apple MC968 Macbook Air"
cbokode.AddItem "Apple MC969 Macbook Air"
cbokode.AddItem "Apple MC700 Macbook Pro"
cbokode.AddItem "Apple MC721 Macbook Pro"
cbokode.AddItem "Apple MC723 Macbook Pro"
cbokode.AddItem "Apple MC311 Macbook Pro"
cbokode.AddItem "Apple MC313 Macbook Pro"
cbokode.AddItem "Apple MC314 Macbook Pro"
cbokode.AddItem "Apple MC318 Macbook Pro"
cbokode.AddItem "Apple MC322 Macbook Pro"
cbokode.AddItem "Apple MC965 Macbook Air"
cbokode.AddItem "Apple MC966 Macbook Air"
End Sub

Private Sub cbokode_Click()
Dim mt, hs As String
Select Case Mid(cbokode, 7, 5)
Case "MC965"
mt = "Apple MC965 Macbook Air  "
hs = "12800000"
Case "MC966"
mt = "Apple MC966 Macbook Air  "
hs = "15800000"
Case "MC968"
mt = "Apple MC968 Macbook Air "
hs = "9900000"
Case "MC969"
mt = "Apple MC969 Macbook Air "
hs = "11900000"
Case "MC700"
mt = "Apple MC700 Macbook Pro "
hs = "10800000"
Case "MC721"
mt = "Apple MC721 Macbook Pro  "
hs = "15900000"
Case "MC723"
mt = "Apple MC723 Macbook Pro "
hs = "19300000"
Case "MC724"
mt = "Apple  MC724 Macbook Pro"
hs = "13700000"
Case "MC7311"
mt = "Apple MC311 Macbook Pro "
hs = "24200000"
Case "MC313"
mt = "Apple MC313  Macbook Pro "
hs = "11900000"
Case "MC314"
mt = "Apple MC314 Macbook Pro "
hs = "14700000"
Case "MC318"
mt = "Apple MC318 Macbook Pro  "
hs = "17600000"
Case "MC322"
mt = "Apple MC322 Macbook Pro  "
hs = "21300000"
Case "MC965"
mt = "Apple MC965 Macbook Air "
hs = "12800000"
Case "MC966"
mt = "Apple MC966 Macbook Air "
hs = "15800000"
End Select
txtmerk = mt
txths = hs
txtjj.SetFocus
End Sub

Private Sub cmdhitunglagi_Click()
cbokode.Text = ""
txtmerk.Text = ""
txths.Text = ""
txtjj.Text = ""
txtdis.Text = ""
txttb.Text = ""
txthp = ""
End Sub

Private Sub cmdkeluar_Click()
Unload Me
End Sub

Private Sub cmdproses_Click()
txthp = Val(txtjj) * Val(txths)
If txthp > 140000000 Then
txtdis = (0.15) * Val(txthp)
ElseIf txthp > 135000000 Then
txtdis = (0.1) * Val(txthp)
ElseIf txthp > 130000000 Then
txtdis = (0.5) * Val(txthp)
ElseIf txthp > 125000000 Then
txtdis = (0.2) * Val(txthp)
End If
txttb.Text = Val(txthp) - Val(txtdis)
End Sub

Tugas 3.2 STMIK PRINGSEWU

Tugas 3.2 STMIK PRINGSEWU


Source Codenya:

Private Sub cmdbatal_Click()
txtnama.SetFocus
txtnama = ""
txtnpm = ""
txtjur = ""
txtps = ""
txtnu = ""
txttm.Text = ""
End Sub

Private Sub cmdlagi_Click()
txtnama.SetFocus
txtnama = ""
txtnpm = ""
txtjur = ""
txtps = ""
txtnu = ""
txttm.Text = ""
End Sub

Private Sub cmdkeluar_Click()
Unload Me
End Sub

Private Sub Form_Activate()
txtnama.SetFocus
txtnama = ""
txtnpm = ""
txtjur = ""
txtps = ""
txtnu = ""
End Sub


Private Sub cmdproses_Click()
Dim R As String
txttm.Text = "20" & Left(txtnpm.Text, 2)
R = Mid(txtnpm.Text, 3, 1)
If R = "1" Then
txtjur.Text = "Sistem Informasi"
ElseIf R = "2" Then
txtjur.Text = "Manajemen Informatika"
ElseIf R = "3" Then
txtjur.Text = "Teknik Informatika"
ElseIf R = "4" Then
txtjur.Text = "Manajemen & Komp.Akuntansi"
End If
R = Mid(txtnpm.Text, 4, 2)
If R = "01" Then
txtps.Text = "Strata satu"
ElseIf R = "02" Then
txtps.Text = "Diploma 1"
ElseIf R = "03" Then
txtps.Text = "Diploma 2"
ElseIf R = "04" Then
txtps.Text = "Diploma 3"
End If
txtnu.Text = Right(txtnpm.Text, 3)
End Sub

Private Sub txtnama_keypress(keyascii As Integer)
If keyascii = 13 Then
txtnpm.SetFocus
End If
End Sub

Private Sub txtnpm_keypress(keyascii As Integer)
Dim R As String
txttm.Text = "20" & Left(txtnpm.Text, 2)
R = Mid(txtnpm.Text, 3, 1)
If R = "1" Then
txtjur.Text = "Sistem Informasi"
ElseIf R = "2" Then
txtjur.Text = "Manajemen Informatika"
ElseIf R = "3" Then
txtjur.Text = "Teknik Informatika"
ElseIf R = "4" Then
txtjur.Text = "Manajemen & Komp.Akuntansi"
End If
R = Mid(txtnpm.Text, 4, 2)
If R = "01" Then
txtps.Text = "Strata satu"
ElseIf R = "02" Then
txtps.Text = "Diploma 1"
ElseIf R = "03" Then
txtps.Text = "Diploma 2"
ElseIf R = "04" Then
txtps.Text = "Diploma 3"
End If
txtnu.Text = Right(txtnpm.Text, 3)
End Sub

Tugas 3.1 Program Gaji

Tugas 3.1 Program Gaji 



Source Codenya:

Private Sub Cmdbatal_Click()
kosong
End Sub

Private Sub cmdlagi_Click()
kosong
End Sub

Public Sub kosong()
txtnidn.SetFocus
txtnidn.Text = ""
txtnama.Text = ""
cbogolongan.Text = ""
txtgp.Text = ""
txttj.Text = ""
txtpj.Text = ""
txttotal.Text = ""
End Sub

Private Sub cbogolongan_Click()
Dim gapok, pajak, tunjangan, total As Variant
Select Case cbogolongan.Text
Case "I"
gapok = 2000000
tunjangan = 1500000
Case "II"
gapok = 3000000
tunjangan = 2500000
Case "III"
gapok = 4000000
tunjangan = 3500000
Case "IV"
gapok = 5000000
tunjangan = 4500000
Case Else
gapok = 0
tunjangan = 0
End Select
total = gapok + tunjangan
pajak = total * 0.1
txtgp.Text = gapok
txttj.Text = tunjangan
txtpj.Text = pajak
txttotal.Text = total - pajak
End Sub

Private Sub cmdkeluar_Click()
Unload Me
End Sub

Private Sub Form_Load()
cbogolongan.AddItem "I"
cbogolongan.AddItem "II"
cbogolongan.AddItem "III"
cbogolongan.AddItem "IV"
End Sub

Private Sub txtnidn_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtnama.SetFocus
End If
End Sub

Senin, 20 November 2017

Tugas 2.8 Huruf Mutu Mahasiswa Stmik Pringsewu Menggunakan keypress

Tugas 2.8 Huruf Mutu Mahasiswa Stmik Pringsewu  Menggunakan keypress



Berikut Source Codenya:


Private Sub cbonpm_click()
Dim nama, jurusan, hm As String

Select Case cbonpm.Text
Case "17100001"
nama = "Mardalena"
jurusan = "Sistem Informasi"
Case "17100002"
nama = "Bahadi Rhamadani"
jurusan = "Sistem Informasi"
Case "17100003"
nama = "Renaldi Zainal Arifin"
jurusan = "Sistem Informasi"
Case "17100004"
nama = "Eka Kartika"
jurusan = "Sistem Informasi"
Case "17100006"
nama = "Rosi elvia"
jurusan = "Sistem Informasi"
Case "17100008"
nama = "M.Galih algofur"
jurusan = "Sistem Informasi"
Case "17100010"
nama = "Novia Anggraini"
jurusan = "Sistem Informasi"
Case "17100011"
nama = "Ariansyah"
jurusan = "Sistem Informasi"
Case "17100012"
nama = "Dimas Apringga"
jurusan = "Sistem Informasi"
Case "17100013"
nama = "Irmanida Siswanti"
jurusan = "Sistem Informasi"
End Select
txtmhs.Text = nama
txtjur.Text = jurusan
txtquis.SetFocus
End Sub
'renaldi Zainal arifin

Private Sub cmdbatal_Click()
cbonpm.SetFocus
cbonpm.Text = ""
txtmhs.Text = ""
txtjur.Text = ""
txtquis.Text = ""
txttgs.Text = ""
txtuts.Text = ""
txtuas.Text = ""
txtna.Text = ""
txthm.Text = ""
End Sub


Private Sub cmdproses_Click()
Dim na As Integer
Dim hm As String
quis = Val(txtquis.Text)
tugas = Val(txttgs.Text)
uts = Val(txtuts.Text)
uas = Val(txtuas.Text)
na = (quis + tugas + uts + uas) / 4
txtna.Text = na

Select Case txtna.Text
Case Is > 80
hm = "A"
Case Is > 70
hm = "B"
Case Is > 60
hm = "C"
Case Is > 50
hm = "D"
Case Is < 50
hm = "E"
End Select
txthm.Text = hm
End Sub

Private Sub cmdquit_Click()
Unload Me
End Sub

Private Sub Form_Load()
cbonpm.AddItem "17100001"
cbonpm.AddItem "17100002"
cbonpm.AddItem "17100003"
cbonpm.AddItem "17100004"
cbonpm.AddItem "17100006"
cbonpm.AddItem "17100008"
cbonpm.AddItem "17100010"
cbonpm.AddItem "17100011"
cbonpm.AddItem "17100012"
cbonpm.AddItem "17100013"
End Sub

Private Sub txtquis_keypress(keyascii As Integer)
If keyascii = 13 Then
txttgs.SetFocus
End If
End Sub

Private Sub Txttgs_keypress(keyascii As Integer)
If keyascii = 13 Then
txtuts.SetFocus
End If
End Sub

Private Sub txtuts_keypress(keyascii As Integer)
If keyascii = 13 Then
txtuas.SetFocus
End If
End Sub

Private Sub txtuas_keypress(keyascii As Integer)
If keyascii = 13 Then
Dim na As Integer
Dim hm As String
quis = Val(txtquis.Text)
tugas = Val(txttgs.Text)
uts = Val(txtuts.Text)
uas = Val(txtuas.Text)
na = (quis + tugas + uts + uas) / 4
txtna.Text = na
'Renaldi zainal arifin
Select Case txtna.Text
Case Is > 80
hm = "A"
Case Is > 70
hm = "B"
Case Is > 60
hm = "C"
Case Is > 50
hm = "D"
Case Is < 50
hm = "E"
End Select
txthm.Text = hm
End If
End Sub

Tugas 2.7 Huruf Mutu Mahasiswa Stmik Pringsewu tanpa keypress

Tugas 2.7 Huruf Mutu Mahasiswa Stmik Pringsewu 

tanpa keypress

 


Berikut Source Codenya:


Private Sub cbonpm_click()
Dim nama, jurusan, hm As String

Select Case cbonpm.Text
Case "17100001"
nama = "Mardalena"
jurusan = "Sistem Informasi"
Case "17100002"
nama = "Bahadi Rhamadani"
jurusan = "Sistem Informasi"
Case "17100003"
nama = "Renaldi Zainal Arifin"
jurusan = "Sistem Informasi"
Case "17100004"
nama = "Eka Kartika"
jurusan = "Sistem Informasi"
Case "17100006"
nama = "Rosi elvia"
jurusan = "Sistem Informasi"
Case "17100008"
nama = "M.Galih algofur"
jurusan = "Sistem Informasi"
Case "17100010"
nama = "Novia Anggraini"
jurusan = "Sistem Informasi"
Case "17100011"
nama = "Ariansyah"
jurusan = "Sistem Informasi"
Case "17100012"
nama = "Dimas Apringga"
jurusan = "Sistem Informasi"
Case "17100013"
nama = "Irmanida Siswanti"
jurusan = "Sistem Informasi"
End Select
txtmhs.Text = nama
txtjur.Text = jurusan
txtquis.SetFocus
End Sub
'renaldi Zainal arifin

Private Sub cmdbatal_Click()
cbonpm.SetFocus
cbonpm.Text = ""
txtmhs.Text = ""
txtjur.Text = ""
txtquis.Text = ""
txttgs.Text = ""
txtuts.Text = ""
txtuas.Text = ""
txtna.Text = ""
txthm.Text = ""
End Sub


Private Sub cmdproses_Click()
Dim na As Integer
Dim hm As String
quis = Val(txtquis.Text)
tugas = Val(txttgs.Text)
uts = Val(txtuts.Text)
uas = Val(txtuas.Text)
na = (quis + tugas + uts + uas) / 4
txtna.Text = na

Select Case txtna.Text
Case Is > 80
hm = "A"
Case Is > 70
hm = "B"
Case Is > 60
hm = "C"
Case Is > 50
hm = "D"
Case Is < 50
hm = "E"
End Select
txthm.Text = hm
End Sub

Private Sub cmdquit_Click()
Unload Me
End Sub

Private Sub Form_Load()
cbonpm.AddItem "17100001"
cbonpm.AddItem "17100002"
cbonpm.AddItem "17100003"
cbonpm.AddItem "17100004"
cbonpm.AddItem "17100006"
cbonpm.AddItem "17100008"
cbonpm.AddItem "17100010"
cbonpm.AddItem "17100011"
cbonpm.AddItem "17100012"
cbonpm.AddItem "17100013"
End Sub