Tugas.3 VB Membuat Program 1-9

1.

gambar1

Private Sub Chkbold_Click()
If Chkbold.Value = 1 Then
Lblmv.FontBold = True
Else
Lblmv.FontBold = False
End If
End Sub

Private Sub Chkitalic_Click()
If Chkitalic.Value = 1 Then
Lblmv.FontItalic = True
Else
Lblmv.FontItalic = False
End If
End Sub

Private Sub Chkstrike_Click()
If Chkstrike.Value = 1 Then
Lblmv.FontStrikethru = True
Else
Lblmv.FontStrikethru = False
End If
End Sub

Private Sub Chkunder_Click()
If Chkunder.Value = 1 Then
Lblmv.FontUnderline = True
Else
Lblmv.FontUnderline = False
End If
End Sub

Private Sub Comexit_Click()
End
End Sub

Private Sub Optblue_Click()
Lblmv.ForeColor = vbBlue
End Sub

Private Sub Optgreen_Click()
Lblmv.ForeColor = vbGreen
End Sub

Private Sub Optred_Click()
Lblmv.ForeColor = vbRed
End Sub

Private Sub Optyellow_Click()
Lblmv.ForeColor = vbYellow
End Sub

2.

gambar2

Private Sub Comhitung_Click()
Dim a, b, c As Double
Txtb.Text = Val(txta.Text) * 0.1
Txtc.Text = Val(txta.Text) – Val(Txtb.Text)
End Sub

Private Sub Comquit_Click()
End
End Sub

Private Sub Comulang_Click()
txta = “”
Txtb = “”
Txtc = “”
End Sub

3.

gambar3

Private Sub Comkeluar_Click()
End
End Sub

Private Sub Comproses_Click()
Dim a, b, c, d, e, f As Double
Txtd.Text = Val(Txta.Text) + Val(Txtb.Text) – Val(Txtc.Text)
Txte.Text = Val(Txtd.Text) * (0.1)
Txtf.Text = Val(Txtd.Text) – Val(Txte.Text)
End Sub

Private Sub Comulang_Click()
Txta.SetFocus
Txta = “”
Txtb = “”
Txtc = “”
Txtd = “”
Txte = “”
Txtf = “”
End Sub

4.

gambar4

Private Sub Combatal_Click()
Combonpm.SetFocus
Combonpm.Text = “”
Txtnama.Text = “”
Txtjurusan.Text = “”
Txtquiss.Text = “”
Txttugas.Text = “”
Txtuts.Text = “”
Txtuas.Text = “”
Txtnilai.Text = “”
Txthm.Text = “”
End Sub

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

Select Case Combonpm.Text
Case “12201174”
nama = “Rosidah Nur Fadilah”
jurusan = “Manajement Informatika”
Case “09200048”
nama = “Amalia Amanah”
jurusan = “Sistem Informasi”
Case “09300024”
nama = “Saskia Meca”
jurusan = “Teknik Informatika”
End Select
Txtnama.Text = nama
Txtjurusan.Text = jurusan
Txtquiss.SetFocus
End Sub

Private Sub Comkeluar_Click()
Unload Me
End Sub

Private Sub Comproses_Click()
Dim nilai As Integer
Dim hm As String
quiss = Val(Txtquiss.Text)
tugas = Val(Txttugas.Text)
uts = Val(Txtuts.Text)
uas = Val(Txtuas.Text)
nilai = (quiss + tugas + uts + uas) / 4
Txtnilai.Text = nilai

Select Case Txtnilai.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 Form_Load()
Combonpm.AddItem “12201174”
Combonpm.AddItem “09200048”
Combonpm.AddItem “09300024”
End Sub

Private Sub Txtquiss_keypress(keyascii As Integer)
If keyascii = 13 Then
Txttugas.SetFocus
End If
End Sub

Private Sub Txttugas_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

5.

gambar5

Private Sub Chkmiring_Click()
Lblnama.FontItalic = Chkmiring
End Sub

Private Sub Chktebal_Click()
Lblnama.FontBold = Chktebal.Value
End Sub

Private Sub Comok_Click()
Lblnama.Caption = txtnama.Text
End Sub

Private Sub Comselesai_Click()
End
End Sub

Private Sub Optkuning_Click()
Lblnama.ForeColor = vbYellow
End Sub

Private Sub Optmerah_Click()
Lblnama.ForeColor = vbRed
End Sub

6.

gambar6
Private Sub Combatal_Click()
Txtnidn.SetFocus
Txtnidn.Text = “”
Txtnama.Text = “”
Combogolongan.Text = “”
Txtgaji.Text = “”
Txttunjangan.Text = “”
Txtpajak.Text = “”
Txttotal.Text = “”
End Sub

Private Sub Combogolongan_Click()
Dim gaji, pajak, tunjangan, total As Variant
Select Case Combogolongan.Text
Case “I”
gaji = 1500000
tunjangan = 150000
Case “II”
gaji = 2000000
tunjangan = 200000
Case “III”
gaji = 2500000
tunjangan = 250000
Case “IV”
gaji = 3000000
tunjangan = 300000
Case Else
gaji = 0
tunjangan = 0
End Select
total = gaji + tunjangan
pajak = total * 0.1
Txtgaji.Text = gaji
Txttunjangan.Text = tunjangan
Txtpajak.Text = pajak
Txttotal.Text = total – pajak
End Sub
Private Sub Comkeluar_Click()
Unload Me
End Sub

Private Sub comlagi_Click()
Txtnidn.SetFocus
Txtnidn.Text = “”
Txtnama.Text = “”
Combogolongan.Text = “”
Txtgaji.Text = “”
Txttunjangan.Text = “”
Txtpajak.Text = “”
Txttotal.Text = “”
End Sub

Private Sub Form_Load()
Combogolongan.AddItem “I”
Combogolongan.AddItem “II”
Combogolongan.AddItem “III”
Combogolongan.AddItem “IV”
End Sub

Private Sub Txtnidn_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtnama.SetFocus
End If
End Sub

7.

gambar7

Private Sub Combatal_Click()
Txtnama.SetFocus
Txtnama.Text = “”
txtnpm.Text = “”
Txtjurusan.Text = “”
Txtps.Text = “”
Txttm.Text = “”
Txturut.Text = “”
End Sub

Private Sub Comkeluar_Click()
Unload Me
End Sub

Private Sub Comlagi_Click()
Txtnama.SetFocus
Txtnama.Text = “”
txtnpm.Text = “”
Txtjurusan.Text = “”
Txtps.Text = “”
Txttm.Text = “”
Txturut.Text = “”
End Sub

Private Sub Comproses_Click()
Dim s As String
Txttm.Text = “20” & Left(txtnpm.Text, 2)
s = Mid(txtnpm.Text, 3, 1)
If s = “1” Then
Txtjurusan.Text = “Sistem Informasi”
ElseIf s = “2” Then
Txtjurusan.Text = “Manajemen Informatika”
ElseIf s = “3” Then
Txtjurusan.Text = “Teknik Informatika”
ElseIf s = “4” Then
Txtjurusan.Text = “Manajemen & Komputer Akuntansi”
End If
s = Mid(txtnpm.Text, 4, 2)
If s = “01” Then
Txtps.Text = “strata satu”
ElseIf s = “02” Then
Txtps.Text = “diploma tiga”
ElseIf s = “03” Then
Txtps.Text = “diploma empat”
ElseIf s = “04” Then
Txtps.Text = “diploma dua”
End If
Txturut.Text = Right(txtnpm.Text, 3)
End Sub

Private Sub Form_Activate()
Txtnama.SetFocus
Txtnama.Text = “”
txtnpm.Text = “”
Txtjurusan.Text = “”
Txtps.Text = “”
Txttm.Text = “”
Txturut.Text = “”
End Sub

Private Sub Txtnama_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtnpm.SetFocus
End If
End Sub

8.

gambar8

Private Sub Combersih_Click()
Txtnilai1.Text = “”
Txtnilai2.Text = “”
Txthasil.Text = “”
End Sub

Private Sub Comhitung_Click()
Dim a As Single
Dim b As Single
a = Txtnilai1.Text
b = Txtnilai2.Text
hasil = a * b
Txthasil.Text = hasil
End Sub

Private Sub Comkeluar_Click()
End
End Sub

9.

gambar9

Private Sub Comhitung_Click()
Dim a, b, c As Double
Txtdiskon.Text = Val(Txtawal.Text) * 0.2
Txtakhir.Text = Val(Txtawal.Text) – Val(Txtdiskon.Text)
End Sub

Private Sub Comkeluar_Click()
End
End Sub

Private Sub Comlagi_Click()
Txtawal.SetFocus
Txtawal.Text = “”
Txtdiskon.Text = “”
Txtakhir.Text = “”
End Sub

Advertisements

Tugas 2

1

Private Sub Command1_Click()
Text1 = “”
Text2 = “”
Text3 = “”
Text4 = “”
End Sub

Private Sub Command2_Click()
Text1 = “”
Text2 = “”
Text3 = “”
Text4 = “”
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Text1_keypress(keyascii As Integer)
If keyascii = 13 Then
Text2.SetFocus
End If
End Sub

Private Sub Text2_keypress(keyascii As Integer)
If keyascii = 13 Then
Text3.SetFocus
End If
End Sub

Private Sub Text3_keypress(keyascii As Integer)
If keyascii = 13 Then
Text4.SetFocus
End If
End Sub

Tugas 6

6

 

Private Sub Combatal_Click()
txtem.SetFocus
txtem = “”
Txthp = “”
Txtharga = “”
Txtjp = “”

End Sub

Private Sub Comkl_Click()
End
End Sub

Private Sub Comok_Click()
If keyascii = 13 Then
Combatal.SetFocus
End If
End Sub

 

Private Sub txtem_keypress(keyascii As Integer)
If keyascii = 13 Then
Txthp.SetFocus
End If

End Sub

Private Sub Txtharga_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtjp.SetFocus
End If

End Sub

Private Sub Txthp_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtharga.SetFocus
End If

End Sub

Private Sub Txtjp_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtsel.SetFocus
End If
End Sub

Private Sub Txtsel_keypress(keyascii As Integer)
Comok.SetFocus
Txtsel.Text = Val(Txtharga.Text) * Val(Txtjp.Text)
End Sub

Tugas 5

5

 

Private Sub Combatal_Click()
Txtnm.SetFocus
Txtnm = “”
Txtnpm = “”
Txtalmt = “”
Txtps = “”
End Sub

Private Sub Comkeluar_Click()
End
End Sub

Private Sub Comlagi_Click()
Txtnm.SetFocus
End Sub

Private Sub Txtalmt_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtps.SetFocus
End If
End Sub

Private Sub Txtnm_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtnpm.SetFocus
End If
End Sub

Private Sub Txtnpm_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtalmt.SetFocus
End If
End Sub

Private Sub Txtps_keypress(keyascii As Integer)
If keyascii = 13 Then
Comlagi.SetFocus
End If
End Sub

Tugas 4

4

 

Private Sub Combersih_Click()
Txtangka1.SetFocus
Txtangka1 = “”
txtangka2 = “”
Txtjuml = “”
End Sub

Private Sub Comhitung_Click()
Combersih.SetFocus
Txtjuml.Text = Val(Txtangka1.Text) * Val(txtangka2.Text)
End Sub

Private Sub Comkeluar_Click()
End
End Sub

Private Sub Txtangka1_keypress(keyascii As Integer)
If keyascii = 13 Then
txtangka2.SetFocus
End If
End Sub

Private Sub txtangka2_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtjuml.SetFocus
End If
End Sub

Private Sub Txtjuml_keypress(keyascii As Integer)
If keyascii = 13 Then
Comhitung.SetFocus
End If
End Sub

 

Tugas 3

3

 

Private Sub Comhitung_Click()
Txtjum.Text = Val(Txtni1.Text) + Val(Txtni2.Text)
Txtkali.Text = Val(Txtni1.Text) * Val(Txtni2.Text)
Txtkurang.Text = Val(Txtni1.Text) – Val(Txtni2.Text)
Txtbagi.Text = Val(Txtni1.Text) / Val(Txtni2.Text)
End Sub

Private Sub Comkl_Click()
End
End Sub

Private Sub Comlagi_Click()
Txtni1.SetFocus
Txtni1 = “”
Txtni2 = “”
Txtjum = “”
Txtkali = “”
Txtkurang = “”
Txtbagi = “”
End Sub

Private Sub Txtni1_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtni2.SetFocus
End If
End Sub

Private Sub Txtni2_keypress(keyascii As Integer)
If keyascii = 13 Then
Comhitung.SetFocus
End If
End Sub

 

Tugas 1

1

 

Private Sub Combt_Click()
txtnpm.SetFocus
txtnpm = “”
txtnm = “”
Txtal = “”
Txtju = “”
Txtps = “”
End Sub

Private Sub Comkl_Click()
End
End Sub

Private Sub Comul_Click()
Combt.SetFocus
txtnpm = “”
txtnm = “”
Txtal = “”
Txtju = “”
Txtps = “”
End Sub

Private Sub Txtal_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtju.SetFocus
End If
End Sub

Private Sub Txtju_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtps.SetFocus
End If
End Sub

Private Sub txtnm_keypress(keyascii As Integer)
If keyascii = 13 Then
Txtal.SetFocus
End If
End Sub

Private Sub txtnpm_keypress(keyascii As Integer)
If keyascii = 13 Then
txtnm.SetFocus
End If
End Sub

Private Sub Txtps_keypress(keyascii As Integer)
If keyascii = 13 Then
Comul.SetFocus
End If
End Sub

 

keceriaan hidup