14
TUGAS VISUAL BASIC YAHOO1 NAMA :ABID RAHMAT SATRIA PUTRA KELAS :YAHOO1 NPM :11100035 GAMBAR APLIKASI YANG AKAN DIBERI KODE

abitrahmatstmikpringsewu.files.wordpress.com… · Web viewtugas visual basic yahoo1. nama:abid rahmat satria putra. kelas:yahoo1. npm:11100035. gambar aplikasi yang akan diberi kode

Embed Size (px)

Citation preview

TUGAS VISUAL BASIC YAHOO1

NAMA :ABID RAHMAT SATRIA PUTRA

KELAS :YAHOO1

NPM :11100035

GAMBAR APLIKASI YANG AKAN DIBERI KODE

ISI DARI PROGRAM DIATAS

Private Sub cmdbatal_Click()txtkd.SetFocustxtkd.Text = ""txtnama.Text = ""txtjumlah.Text = ""txtsisa.Text = ""txtterjual.Text = ""txtharga.Text = ""txttotal.Text = ""End Sub

Private Sub cmdkeluar_Click()Unload MeEnd Sub

Private Sub cmdproses_Click()

Dim A As StringA = txtkd.Text

If A = "HB002T" Thentxtnama.Text = "TAPE"txtharga.Text = "275000"

ElseIf A = "TH002S" Thentxtnama.Text = "SOUND SYSTEM"txtharga.Text = "350000"

ElseIf A = "HB002C" Thentxtnama.Text = "COMPACT"txtharga.Text = "480000"End If

txtjumlah.SetFocus

End Sub

Private Sub txtjumlah_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Thentxtsisa.SetFocusEnd IfEnd Sub

Private Sub txtsisa_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Thentxtterjual.Text = Val(txtjumlah.Text) - Val(txtsisa.Text)txttotal.Text = Val(txtterjual.Text) * Val(txtharga.Text)End IfEnd Sub

Private Sub txttotal_Change()txtterbilang.Text = terbilang(Val(txttotal.Text))End Sub

Private Function KeKata(Nomor)TrjKata = Array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan")KeKata = TrjKata(Nomor)End FunctionPublic Function terbilang(Nilai_Angka, Optional Style = 4, Optional Satuan = " rupiah")Angka = Fix(Abs(Nilai_Angka))des1 = Mid(Abs(Nilai_Angka), Len(Angka) + 2, 1)des2 = Mid(Abs(Nilai_Angka), Len(Angka) + 3, 1)If des2 = "" ThenIf des1 = "" Or des1 = "0" ThenKoma = ""ElseKoma = "koma" & KeKata(des1)End IfElseIf des2 = "0" ThenIf des1 = "0" ThenKoma = ""ElseIf des1 = "1" ThenKoma = "koma sepuluh"ElseKoma = "koma" & KeKata(des1) & "puluh"End IfElseIf des1 = "0" ThenKoma = "koma nol" & KeKata(des2)ElseIf des1 = "1" ThenIf des2 = "1" ThenKoma = "koma sebelas"ElseKoma = "koma" & KeKata(des2) & "belas"End IfElseKoma = "koma" & KeKata(des1) & "puluh" & KeKata(des2)End IfEnd IfNo1 = Left(Right(Angka, 1), 1)No2 = Left(Right(Angka, 2), 1)

No3 = Left(Right(Angka, 3), 1)No4 = Left(Right(Angka, 4), 1)No5 = Left(Right(Angka, 5), 1)No6 = Left(Right(Angka, 6), 1)No7 = Left(Right(Angka, 7), 1)No8 = Left(Right(Angka, 8), 1)No9 = Left(Right(Angka, 9), 1)No10 = Left(Right(Angka, 10), 1)No11 = Left(Right(Angka, 11), 1)No12 = Left(Right(Angka, 12), 1)No13 = Left(Right(Angka, 13), 1)No14 = Left(Right(Angka, 14), 1)No15 = Left(Right(Angka, 15), 1)If Len(Angka) >= 1 ThenIf Len(Angka) = 1 And No1 = 1 ThenNomor1 = "satu"ElseIf Len(Angka) = 1 And No1 = 0 ThenNomor1 = "Nol"ElseIf No2 = "1" ThenIf No1 = "1" ThenNomor1 = "sebelas"ElseIf No1 = "0" ThenNomor1 = "sepuluh"ElseNomor1 = KeKata(No1) & "belas"End IfElseNomor1 = KeKata(No1)End IfElseNomor1 = ""End IfIf Len(Angka) >= 2 ThenIf No2 = 1 Or No2 = "0" ThenNomor2 = ""ElseNomor2 = KeKata(No2) & "puluh"End IfElseNomor2 = ""End IfIf Len(Angka) >= 3 ThenIf No3 = "1" ThenNomor3 = "seratus"ElseIf No3 = "0" ThenNomor3 = ""ElseNomor3 = KeKata(No3) & "ratus"End IfElseNomor3 = ""End IfIf Len(Angka) >= 4 ThenIf No6 = "0" And No5 = "0" And No4 = "0" ThenNomor4 = ""ElseIf (No4 = "1" And Len(Angka) = 4) Or (No6 = "0" And No5 = "0" And No4 = "1") Then

Nomor4 = "seribu "ElseIf No5 = "1" ThenIf No4 = "1" ThenNomor4 = "sebelas ribu"ElseIf No4 = "0" ThenNomor4 = "sepuluh ribu"ElseNomor4 = KeKata(No4) & "belas ribu"End IfElseNomor4 = KeKata(No4) & "ribu"End IfElseNomor4 = ""End IfIf Len(Angka) >= 5 ThenIf No5 = "1" Or No5 = "0" ThenNomor5 = ""ElseNomor5 = KeKata(No5) & "puluh"End IfElseNomor5 = ""End IfIf Len(Angka) >= 6 ThenIf No6 = "1" ThenNomor6 = "seratus"ElseIf No6 = "0" ThenNomor6 = ""ElseNomor6 = KeKata(No6) & "ratus"End IfElseNomor6 = ""End IfIf Len(Angka) >= 7 ThenIf No9 = "0" And No8 = "0" And No7 = "0" ThenNomor7 = ""ElseIf No7 = "1" And Len(Angka) = 7 ThenNomor7 = "satujuta"ElseIf No8 = "1" ThenIf No7 = "1" ThenNomor7 = "sebelas juta"ElseIf No7 = "0" ThenNomor7 = "sepuluh juta"ElseNomor7 = KeKata(No7) & "belas juta"End IfElseNomor7 = KeKata(No7) & "juta"End IfElseNomor7 = ""End IfIf Len(Angka) >= 8 ThenIf No8 = "1" Or No8 = "0" ThenNomor8 = ""

ElseNomor8 = KeKata(No8) & "puluh"End IfElseNomor8 = ""End IfIf Len(Angka) >= 9 ThenIf No9 = "1" ThenNomor9 = "seratus"ElseIf No9 = "0" ThenNomor9 = ""ElseNomor9 = KeKata(No9) & "ratus"End IfElseNomor9 = ""End IfIf Len(Angka) >= 10 ThenIf No12 = "0" And No11 = "0" And No10 = "0" ThenNomor10 = ""ElseIf No10 = "1" And Len(Angka) = 10 ThenNomor10 = "satu milyar"ElseIf No11 = "1" ThenIf No10 = "1" ThenNomor10 = "sebelas milyar"ElseIf No10 = "0" ThenNomor10 = "sepuluh milyar"ElseNomor10 = KeKata(No10) & "belas milyar"End IfElseNomor10 = KeKata(No10) & "milyar"End IfElseNomor10 = ""End IfIf Len(Angka) >= 11 ThenIf No11 = "1" Or No11 = "0" ThenNomor11 = ""ElseNomor11 = KeKata(No11) & "puluh"End IfElseNomor11 = ""End IfIf Len(Angka) >= 12 ThenIf No12 = "1" ThenNomor12 = "seratus"ElseIf No12 = "0" ThenNomor12 = ""ElseNomor12 = KeKata(No12) & "ratus"End IfElseNomor12 = ""End IfIf Len(Angka) >= 13 Then

If No15 = "0" And No14 = "0" And No13 = "0" ThenNomor13 = ""ElseIf No13 = "1" And Len(Angka) = 13 ThenNomor13 = "satu triliun"ElseIf No14 = "1" ThenIf No13 = "1" ThenNomor13 = "sebelas triliun"ElseIf No13 = "0" ThenNomor13 = "sepuluh triliun"ElseNomor13 = KeKata(No13) & "belas triliun"End IfElseNomor13 = KeKata(No13) & "triliun"End IfElseNomor13 = ""End IfIf Len(Angka) >= 14 ThenIf No14 = "1" Or No14 = "0" ThenNomor14 = ""ElseNomor14 = KeKata(No14) & "puluh"End IfElseNomor14 = ""End IfIf Len(Angka) >= 15 ThenIf No15 = "1" ThenNomor15 = "seratus"ElseIf No15 = "0" ThenNomor15 = ""ElseNomor15 = KeKata(No15) & "ratus"End IfElseNomor15 = ""End IfIf Len(Angka) >= 15 Thenbilang = "Digit Angka Terlalu Banyak"ElseIf IsNull(Nilai_Angka) Thenbilang = ""ElseIf Nilai_Angka <= 0 Thenbilang = "" & Trim(Nomor15 & Nomor14 & Nomor13 & Nomor12 & Nomor11 & Nomor10 & Nomor9 & Nomor8 & Nomor7 _& Nomor6 & Nomor5 & Nomor4 & Nomor3 & Nomor2 & Nomor1 & Koma & "" & Satuan)Elsebilang = Trim(Nomor15 & Nomor14 & Nomor13 & Nomor12 & Nomor11 & Nomor10 & Nomor9 & Nomor8 & Nomor7 _& Nomor6 & Nomor5 & Nomor4 & Nomor3 & Nomor2 & Nomor1 & Koma & "" & Satuan)End IfEnd IfIf Style = 4 Thenterbilang = StrConv(Left(bilang, 1), 1) & StrConv(Mid(bilang, 2, 1000), 2)Elseterbilang = StrConv(bilang, Style)

End Ifterbilang = Replace(terbilang, " ", " ", 1, 1000, vbTextCompare)End Function

SETELAH DITEKAN F5, MAKA AKAN JADI

DAN PROGRAM APLIKASI SUDAH DAPAT DIJALANKAN

Misal: kode “HB002T”, stok “500”, sisa “50”