TUGAS VISUAL BASIV SUSULAN KE 4

Judul Buku Stmik

Private Sub Cmdbtl_Click()
Txtkbu.SetFocus
Txtkbu.Text = “”
Txtjbu.Text = “”
Txtpeng.Text = “”
Txtthn.Text = “”
Txtpnr.Text = “”
Txthrg.Text = “”
End Sub

Private Sub Cmdexit_Click()
Unload Me
End Sub

Private Sub Cmdlagi_Click()
Txtkbu.SetFocus
Txtkbu.Text = “”
Txtjbu.Text = “”
Txtpeng.Text = “”
Txtthn.Text = “”
Txtpnr.Text = “”
Txthrg.Text = “”
End Sub

Private Sub Cmdproses_Click()
Dim P As String
Txtthn.Text = “20” & Right(Txtkbu.Text, 2)
P = Left(Txtkbu.Text, 1)
If P = “A” Then
Pn = “Andi Offset Yogyakarta”
ElseIf P = “I” Then
Pn = “Indah Surabaya”
ElseIf P = “S” Then
Pn = “Salemba Empat”
ElseIf P = “E” Then
Pn = “Elek Media Komputindo”
ElseIf P = “M” Then
Pn = “Maxicom”
End If
P = Mid(Txtkbu.Text, 3, 3)
If P = “SIM” Then
Jbk = “Sisitem Informasi Manajemen”
Png = “Andra Setiawan”
Hrg = “75900”
ElseIf P = “EDP” Then
Jbk = “Elektronik Data Processing”
Png = “Desi Istiqomah”
Hrg = “62000”
ElseIf P = “MNJ” Then
Jbk = “Manajemen”
Png = “Sandy Fitrajaya”
Hrg = “42000”
ElseIf P = “CDR” Then
Jbk = “Corel draw”
Png = “Tri Indah Sari”
Hrg = “53000”
ElseIf P = “RPL” Then
Jbk = “Rekayasa Perangkat Lunak”
Png = “Ernita”
Hrg = “83000”
End If
Txtpnr.Text = Pn
Txtjbu.Text = Jbk
Txtpeng.Text = Png
Txthrg.Text = Hrg
End Sub

ataBuku Stmik

Private Sub form_load()
Cbokod.AddItem “A-SIM-01”
Cbokod.AddItem “I-EDP-02”
Cbokod.AddItem “S-MNJ-03”
Cbokod.AddItem “E-CDR-O4”
Cbokod.AddItem “M-RPL-05”
End Sub

Private Sub Cmdbtl_Click()
Cbokod.SetFocus
Cbokod.Text = “”
Txtjbu.Text = “”
Txtpeng.Text = “”
Txtthn.Text = “”
Txtpnr.Text = “”
Txthrg.Text = “”
End Sub

Private Sub Cmdexit_Click()
Unload Me
End Sub

Private Sub Cmdlagi_Click()
Cbokod.SetFocus
Cbokod.Text = “”
Txtjbu.Text = “”
Txtpeng.Text = “”
Txtthn.Text = “”
Txtpnr.Text = “”
Txthrg.Text = “”
End Sub

Private Sub Cmdproses_Click()
Dim P As String
Txtthn.Text = “20” & Right(Cbokod.Text, 2)
P = Left(Cbokod.Text, 1)
If P = “A” Then
Pn = “Andi Offset Yogyakarta”
ElseIf P = “I” Then
Pn = “Indah Surabaya”
ElseIf P = “S” Then
Pn = “Salemba Empat”
ElseIf P = “E” Then
Pn = “Elek Media Komputindo”
ElseIf P = “M” Then
Pn = “Maxicom”
End If
P = Mid(Cbokod.Text, 3, 3)
If P = “SIM” Then
Jbk = “Sisitem Informasi Manajemen”
Png = “Yati Nur Oktavia”
Hrg = “75900”
ElseIf P = “EDP” Then
Jbk = “Elektronik Data Processing”
Png = “Imam Tarmizi”
Hrg = “62000”
ElseIf P = “MNJ” Then
Jbk = “Manajemen”
Png = “Valentina Mariana Adiwianti”
Hrg = “42000”
ElseIf P = “CDR” Then
Jbk = “Corel draw”
Png = “Riyan Suhadi”
Hrg = “53000”
ElseIf P = “RPL” Then
Jbk = “Rekayasa Perangkat Lunak”
Png = “Sinta Umpu Singa”
Hrg = “83000”
End If
Txtpnr.Text = Pn
Txtjbu.Text = Jbk
Txtpeng.Text = Png
Txthrg.Text = Hrg
End Sub

PT Mencari

Private Sub Cmdbtl_Click()
Txtnm.SetFocus
Txtnm = “”
Txtgol = “”
Txtkod = “”
Txtstat = “”
Txtthn = “”
Txtjab = “”
Txtbag = “”
Txtgpk = “”
Txttun = “”
Txttgj = “”
Txtnik = “”
End Sub

Private Sub Cmdexit_Click()
Unload Me
End Sub

Private Sub Cmdlagi_Click()
Txtnm.SetFocus
Txtnm = “”
Txtgol = “”
Txtkod = “”
Txtstat = “”
Txtthn = “”
Txtjab = “”
Txtbag = “”
Txtgpk = “”
Txttun = “”
Txttgj = “”
Txtnik = “”
End Sub

Private Sub Cmdproses_Click()
Dim Jbt, Bag, Gol, Ks, St As String
Dim Gjp, Tnj, Tgj As Currency
Txtthn.Text = Left(Txtnik.Text, 4)
Pt = Mid(Txtnik.Text, 5, 1)
If Pt = “A” Then
Gol = “A”
Jbt = “Manajer”
Gjp = “4000000”
Tnj = “1025000”
ElseIf Pt = “B” Then
Gol = “B”
Jbt = “Ka.seksi”
Gjp = “3500000”
Tnj = “975000”
ElseIf Pt = “C” Then
Gol = “C”
Jbt = “Staff”
Gjp = “3000000”
Tnj = “925000”
End If

Pt = Mid(Txtnik.Text, 7, 1)
If Pt = “S” Then
Ks = “S”
St = “Single”
ElseIf Pt = “M” Then
Ks = “M”
St = “Menikah”
ElseIf Pt = “J” Then
Ks = “J”
St = “Janda”
ElseIf Pt = “D” Then
Ks = “D”
St = “Duda”
End If

Pt = Right(Txtnik.Text, 3)
If Pt = “KEU” Then
Bag = “Accounting”
ElseIf Pt = “ADM” Then
Bag = “Administrasi”
ElseIf Pt = “SDM” Then
Bag = “General Affair”
ElseIf Pt = “EDP” Then
Bag = “IT Unit”
ElseIf Pt = “SPM” Then
Bag = “Security”
End If
Tgj = Val(Gjp) + Val(Tnj)
Txtgpk.Text = Gjp
Txtjab.Text = Jbt
Txttun.Text = Tnj
Txtstat.Text = St
Txtbag.Text = Bag
Txtgol.Text = Gol
Txtkod.Text = Ks
Txttgj.Text = Tgj
End Sub

Private Sub Txtnm_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Txtnik.SetFocus
End If
End Sub

Advertisements

Tugas Visual Basic Ke 5

visual basik 5

Private Sub CmdBaru_Click()
Data1.Recordset.AddNew
TxtNama.SetFocus
End Sub
Private Sub CmdHapus_Click()
Data1.Recordset.Delete
End Sub

Private Sub CmdKeluar_Click()
Unload Me
End Sub

Private Sub CmdProses_Click()
Dim S As String
TxtTm.Text = “20” & Left(TxtNpm.Text, 2)
S = Mid(TxtNpm.Text, 3, 1)
If S = “1” Then
JUR = “Tehnik Komputer”
ElseIf S = “2” Then
JUR = “Manajemen Informatika”
ElseIf S = “3” Then
JUR = “Tehnik Informatika”
ElseIf S = “4” Then
JUR = “Manajemen & Komp. Akuntansi”
End If
TxtJur.Text = JUR
S = Mid(TxtNpm.Text, 4, 2)
If S = “00” Then
PS = “Strata Satu”
ElseIf S = “01” Then
PS = “Diploma Tiga”
ElseIf S = “02” Then
PS = “Diploma Empat”
ElseIf S = “03” Then
PS = “Diploma Dua”
End If
TxtPs.Text = PS
TxtNu.Text = Right(TxtNpm.Text, 3)
End Sub

Private Sub CmdSimpan_Click()
Data1.Recordset.Update
End Sub

Tugas Visual Basic 2…..

gMB vb 111

Private Sub Cbonpm_Click()
Dim nama, jurusan, hm As String
Select Case Cbonpm.Text
Case “11100572”
nama = “Blacius Kris Febriyanto”
jurusan = “Teknik Komputer”
Case “11100573”
nama = ” Nawa Ismail”
jurusan = “Teknik Informatika”
Case “11100574”
nama = “Noperih Sutopo”
jurusan = “Bahasa Indonesia”
End Select
txtnama.Text = nama
txtjurusan.Text = jurusan
txtquis.SetFocus
End Sub

Private Sub Cmdbatal_Click()
Cbonpm.SetFocus
Cbonpm.Text = “”
txtnama.Text = “”
txtjurusan.Text = “”
txtquis.Text = “”
txttugas.Text = “”
txtuts.Text = “”
txtuas.Text = “”
txtna.Text = “”
txthm.Text = “”
End Sub

Private Sub Cmdkeluar_Click()
Unload Me
End Sub

Private Sub Cmdproses_Click()
Dim na As Integer
Dim hm As String
quis = Val(txtquis.Text)
tugas = Val(txttugas.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 Form_Load()
Cbonpm.AddItem “11100572”
Cbonpm.AddItem “11100573”
Cbonpm.AddItem “11100574”
End Sub

Private Sub Text1_Change()

End Sub

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

gMB vb 222

Private Sub Check1_Click()
Label2.FontBold = Check1.Value
End Sub

Private Sub Check2_Click()
Label2.FontItalic = Check2.Value
End Sub

Private Sub Command1_Click()
Label2.Caption = Text1.Text
End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub Option1_Click()
Label2.ForeColor = vbBlue
End Sub

Private Sub Option2_Click()
Label2.ForeColor = vbRed
End Sub

gMB vb 333

Public Sub kosong()
txtnip.SetFocus
txtnip.Text = “”
txtnama.Text = “”
Cbogolongan.Text = “”
txtgapok.Text = “”
txttunjangan.Text = “”
txtpajak.Text = “”
txttotal.Text = “”
End Sub

Private Sub Cbogolongan_Click()
Dim gapok, pajak, tunjangan, total As Variant
Select Case Cbogolongan.Text
Case “I”
gapok = 1500000
tunjangan = 1500000
Case “II”
gapok = 2000000
tunjangan = 2000000
Case “III”
gapok = 2500000
tunjangan = 2500000
Case “IV”
gapok = 3000000
tunjangan = 3000000
Case Else
gapok = 0
End Select
total = gapok + tunjangan
pajak = total * 0.1
txtgapok.Text = gapok
txttunjangan.Text = tunjangan
txtpajak.Text = pajak
txttotal.Text = total – pajak
End Sub

Private Sub Cmdbatal_Click()
kosong
End Sub

Private Sub Cmdkeluar_Click()
Unload Me
End Sub

Private Sub Cmdlagi_Click()
kosong
End Sub

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

Private Sub Text1_Change()

End Sub

End Sub

Private Sub Text2_Change()

End Sub

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

gMB vb 444

Private Sub Cmdbatal_Click()
txtnama.SetFocus
txtnama.Text = “”
txtnpm.Text = “”
Txtjur.Text = “”
txtps.Text = “”
txttm.Text = “”
txturut.Text = “”
End Sub

Private Sub Cmdkeluar_Click()
Unload Me
End Sub

Private Sub Cmdlagi_Click()
txtnama.SetFocus
txtnama.Text = “”
txtnpm.Text = “”
Txtjur.Text = “”
txtps.Text = “”
txttm.Text = “”
txturut.Text = “”
End Sub

Private Sub Cmdproses_Click()
Dim s As String
txttm.Text = “20” & Left(txtnpm.Text, 2)
s = Mid(txtnpm.Text, 3, 1)
If s = “1” Then
Txtjur.Text = “sistem informasi”
ElseIf s = “2” Then
Txtjur.Text = “manajemen informatika”
ElseIf s = “3” Then
Txtjur.Text = “tehnik komputer”
ElseIf s = “4” Then
Txtjur.Text = “manajemen & Kom.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 = “”
Txtjur.Text = “”
txtps.Text = “”
txttm.Text = “”
txturut.Text = “”
End Sub

Private Sub Text2_Change()

End Sub

Private Sub Text3_Change()

End Sub

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

tugas visual basic

Hay sekarang ane mau posting tentang bagaimana caranya membuat program perkalian 2 bilangan menggunakan visual basic, seperti gambar berikut, yuk ikutin caranya.

 2

  1. Buka aplikasi viisual basic 6.0
  2. Kemudian pilih Standard EXE klik open sampe muncul tampilan sbb.

1

3. Kemudian pada Form1, kita tambahkan label, text dan command sesuai dengan soal yang kita garap tadi

4. Lalu kita dobel klik pada text1 dan masukkan rumus berikut:

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Text2.SetFocus

End If

End Sub

5. Lalu kita dobel klik pada Command1 dan masukkan rumus berikut:

Private Sub Command1_Click()

Text3.Text = Val(Text1.Text) * Val(Text2.Text)

End Sub

6. Lalu kita dobel klik pada Command2 dan masukkan rumus berikut:

Private Sub Command2_Click()

Text1.SetFocus

Text1 = ” “

Text2 = ” “

Text3 = ” “

End Sub

7. Lalu kita dobel klik pada Command3 dan masukkan rumus berikut:

Private Sub Command3_Click()

End

End Sub

8. Selesai, mudah bukan….

Tampilan rumus nya seperti ini:

3

Maka apabila program dijalankan, hasilnya seperti ini:

4

Semoga Postingan ini bermanfaat buat sobat semua…..

Hello sobat semua, masih semangat belajar visual basic?… oke sekarang kita mau buat program aplikasi perhitungan gaji.. yuk kita liat gimana cara buat nya…..

  1. Pastinya buka aplikasi visual basic dulu dong
  2. Buat form seperti berikut ini

11

3. Kode untuk text1 sampai text 3

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.Text = Val(Text1.Text) + Val(Text2.Text) – Val(Text3.Text)

Text5.Text = Val(Text4.Text) * 0.1

Text6.Text = Val(Text4.Text) – Val(Text5.Text)

End If

End Sub

4. Kode untuk command 1 dan 2

Private Sub Command1_Click()

Text1.SetFocus

Text1 = ” “

Text2 = ” “

Text3 = ” “

Text4 = ” “

Text5 = ” “

Text6 = ” “

End Sub

Private Sub Command2_Click()

End

End Sub

5. Selesaiiiii

Berikut hasilnnya:

12

Nah, sobat pasti pernah belanja banyak dan pastinya dapet diskon kan,,, sekarang kita akan buat program tentang diskon,, mau tau caranya, yuk liat…

  1. Buka visual basic
  2. Buat form seperti berikut ini

9

3. Klik 2 kali pada text1, dan masukkan kode berikut:

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Text2.Text = Val(Text1.Text) * 0.2

Text3.Text = Val(Text1.Text) – Val(Text2.Text)

End If

End Sub

4. Klik 2 kali pada command1, dan masukkan kode berikut:

Private Sub Command1_Click()

Text1.SetFocus

Text1 = ” “

Text2 = ” “

Text3 = ” “

End Sub

5. Klik 2 kali pada command2, dan masukkan kode berikut:

Private Sub Command2_Click()

End

End Sub

6. Selesai,, mudah kan,, makanya jangan kapok belajar visual basic

Berikut adalah hasilnya:

10

Halo sobat semua,, yuk kita belajar Visual Basic lagi,, sekarang materinya adalah membuat font style dan font color, penasaran?? Yuk kita buat bareng – bareng…..

  1. Seperti biasa buka dulu aplikasi visual basic nya
  2. Buat form seperti gambar berikut

7

3. Berikut adalah rumus option1 sampai option6 (red-black):

Private Sub Option1_Click()

lbljudul.ForeColor = vbRed

End Sub

Private Sub Option2_Click()

lbljudul.ForeColor = vbBlue

End Sub

Private Sub Option3_Click()

lbljudul.ForeColor = vbGreen

End Sub

Private Sub Option4_Click()

lbljudul.ForeColor = vbYellow

End Sub

Private Sub Option5_Click()

lbljudul.ForeColor = vbWhite

End Sub

Private Sub Option6_Click()

lbljudul.ForeColor = vbBlack

End Sub

4. Dan berikut adalah rumus check1 sampai check3 (bold, italic, underlined)

Private Sub Check1_Click()

If Check1.Value = 1 Then

lbljudul.FontBold = True

Else

lbljudul.FontBold = False

End If

End Sub

Private Sub Check2_Click()

If Check2.Value = 1 Then

lbljudul.FontItalic = True

Else

lbljudul.FontItalic = False

End If

End Sub

Private Sub Check3_Click()

If Check3.Value = 1 Then

lbljudul.FontUnderline = True

Else

lbljudul.FontUnderline = False

End If

End Sub

5. Selesai,,, gampang bukan…

Berikut adalah hasilnya:

8

Oke sobat, semoga postingan ini bermanfaat bagi sobat semua….

Hay sob, klo tadi kita Cuma buat program perkalian aja, tapi sekarang ane mau nambahin lagi program nya menjadi pertambahan, perkalian, pengurangan dan pembagian. Oke gk usah berlama – lama mari kita mulai…

  1. Seperti biasa buka dulu program visual basic nya
  2. Buat lah form seperti berikut (sobat semua pasti dh tau caranya buatnya)…. :)

5

3. Dobel klik pada text1, lalu masukkan Rumus berikut:

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Text2.SetFocus

End If

End Sub

4. Dobel klik pada command1, lalu masukkan rumus berikut:

Private Sub Command1_Click()

Text3.Text = Val(Text1.Text) + Val(Text2.Text)

End Sub

5. Dobel klik pada command2, lalu masukkan rumus berikut:

Private Sub Command2_Click()

Text3.Text = Val(Text1.Text) – Val(Text2.Text)

End Sub

6. Dobel klik pada command3, lalu masukkan rumus berikut:

Private Sub Command3_Click()

Text3.Text = Val(Text1.Text) * Val(Text2.Text)

End Sub

7. Dobel klik pada command4, lalu masukkan rumus berikut:

Private Sub Command4_Click()

Text3.Text = Val(Text1.Text) / Val(Text2.Text)

End Sub

8. Dobel klik pada command5, lalu masukkan rumus berikut:

Private Sub Command5_Click()

Text1.SetFocus

Text1 = ” “

Text2 = ” “

Text3 = ” “

End Sub

9. Dobel klik pada command6, lalu masukkan rumus berikut:

Private Sub Command6_Click()

End

End Sub

10. Selesai, kalian telah membuat kalkulator bilangan..

Hasilnya adalah sebagai berikut:

6