Laporan Praktikum Pemrograman Visual

of 15/15
Laporan Pemrograman Visual I D I S U S U N OLEH: Nama : DESMON KRISTANTO SIAHAAN Nim : 212510056 Jurusan : TEKNIK INFORMATIKA
  • date post

    26-Dec-2015
  • Category

    Documents

  • view

    36
  • download

    1

Embed Size (px)

description

Contoh-Contoh Program Sederhana Menggunakan Visual Basic 6.0

Transcript of Laporan Praktikum Pemrograman Visual

Laporan Pemrograman Visual I

DISUSUN

OLEH:

Nama :DESMON KRISTANTO SIAHAAN Nim :212510056 Jurusan :TEKNIK INFORMATIKA

FAKULTAS ILMU KOMPUTERUNIVERSITAS METHODIST INDONESIAMEDAN

Tampilan Muka Visual Baisc (IDE)/Pengenanalan Visual Basic

Program Kalkulator

Private Sub CmdClose_Click()psn = MsgBox("Apakah Anda Ingin Keluar ???", vbYesNo + vbOKOnly, "Konfirmasi")If psn = vbYes ThenMsgBox "Terima Kasih"EndElse If psn = vbNo Then MsgBox "Loh Kog enggak jadi", vbOKOnly, "Information" End IfEnd IfEnd SubPrivate Sub CmdFrmGanjilGenap_Click()Unload MeFrmNegatifPositif.ShowEnd Sub

Private Sub HscBil1_Change()TxtBil1.Text = HscBil1.ValueEnd Sub

Private Sub HscBil2_Change()TxtBil2.Text = HscBil2.ValueEnd SubPrivate Sub OptBagi_Click()TxtHasil.Text = "Hasilnya adalah: " & Val(TxtBil1.Text) / Val(TxtBil2.Text)End Sub

Private Sub OptKali_Click()TxtHasil.Text = "Hasilnya adalah: " & Val(TxtBil1.Text) * Val(TxtBil2.Text)End Sub

Private Sub OptKurang_Click()TxtHasil.Text = "Hasilnya adalah: " & Val(TxtBil1.Text) - Val(TxtBil2.Text)End Sub

Private Sub OptModulus_Click()TxtHasil.Text = "Hasilnya adalah: " & Val(TxtBil1.Text) Mod Val(TxtBil2.Text)End Sub

Private Sub OptTambah_Click()TxtHasil.Text = "Hasilnya adalah: " & Val(TxtBil1.Text) + Val(TxtBil2.Text)End Sub

Program Bilangan Negatif Positif

Private Sub CmdClose_Click()psn = MsgBox("Apakah Anda Ingin Keluar ???", vbYesNo + vbOKOnly, "Konfirmasi")If psn = vbYes ThenMsgBox "Terima Kasih !!!"EndElse If psn = vbNo Then MsgBox "Loh Kog Enggak Jadi ..!!", vbInformation, "Information" End IfEnd IfEnd Sub

Private Sub CmdFrmKalkulator_Click()Unload MeFrmAritmatika.ShowEnd Sub

Private Sub CmdUlang_Click()TxtBilangan.Text = ""TxtHasil.Text = ""TxtBilangan.SetFocusEnd Sub

Private Sub Form_Activate()TxtBilangan.SetFocusEnd Sub

Private Sub CmdUji_Click()If TxtBilangan.Text = Empty ThenMsgBox "Bilangan Harus Diisi", vbExclamation, "Pengingat"TxtBilangan.SetFocusElseIf Val(TxtBilangan.Text) >= 0 ThenTxtHasil.Text = TxtBilangan.Text & " Adalah Bilangan Positif"Else TxtHasil.Text = TxtBilangan.Text & " Adalah Bilangan Negatif"End IfEnd Sub

Program Mencari Luas Bangun Datar & Ruang

Private Sub Timer1_Timer()LblWaktu.Item(0).Caption = "Jam : " & Time & " Tanggal :" & DateLblWaktu.Item(1).Caption = "Jam : " & Time & " Tanggal :" & DateLblWaktu.Item(2).Caption = "Jam : " & Time & " Tanggal :" & DateEnd Sub

Private Sub Form_Activate()NonAktifLayangNonAktifLingkaranNonAktifSegitigaEnd Sub

Private Sub CmdUlangLayang_Click()BersihLayangEnd SubPrivate Sub CmdKeluarLayang_Click()KeluarLayangEnd Sub

Private Sub NonAktifLayang()TxtDiagonal2.Enabled = FalseTxtLLayang.Enabled = FalseCmdUlangLayang.Enabled = FalseCmdKeluarLayang.Enabled = FalseTxtDiagonal1.SetFocusEnd Sub

Private Sub BersihLayang()TxtDiagonal1.Text = ""TxtDiagonal2.Text = ""TxtLLayang.Text = ""TxtDiagonal1.SetFocusTxtDiagonal2.Enabled = FalseTxtLLayang.Enabled = FalseCmdUlangLayang.Enabled = FalseCmdKeluarLayang.Enabled = FalseEnd Sub

Private Sub TxtDiagonal1_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxtDiagonal2.Enabled = TrueTxtDiagonal2.SetFocusEnd IfEnd Sub

Private Sub TxtDiagonal2_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxtLLayang.Enabled = TrueTxtLLayang.Text = "Luas = " & " " & ((TxtDiagonal1.Text * TxtDiagonal2.Text) / 2) & " " & "cm2"CmdUlangLayang.Enabled = TrueCmdKeluarLayang.Enabled = TrueCmdUlangLayang.SetFocusEnd IfEnd SubPrivate Sub KeluarLayang()Pesan = MsgBox("Exit Form Luas Bangun Datar & Ruang ", vbQuestion + vbYesNo, "Konfirmasi")If Pesan = vbYes ThenMsgBox "Terima Kasih", vbInformation, "Informasi"EndElse If Pesan = vbNo Then MsgBox "Loh Kog Enggak Jadi!!!", vbOKOnly, "Informasi" BersihLayang End IfEnd IfEnd Sub

Private Sub NonAktifLingkaran()TxtLLingkaran.Enabled = FalseCmdUlangLingkaran.Enabled = FalseCmdKeluarLingkaran.Enabled = FalseTxtJariJari.SetFocusEnd Sub

Private Sub TxtJariJari_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxtLLingkaran.Enabled = TrueTxtLLingkaran.Text = "Luas =" & " " & 3.14 * TxtJariJari * TxtJariJari & " " & "cm2"CmdUlangLingkaran.Enabled = TrueCmdKeluarLingkaran.Enabled = TrueCmdUlangLingkaran.SetFocusEnd IfEnd Sub

Private Sub CmdUlangLingkaran_Click()BersihLingkaranEnd Sub

Private Sub BersihLingkaran()TxtJariJari.Text = ""TxtLLingkaran.Text = ""CmdUlangLingkaran.Enabled = FalseCmdKeluarLingkaran.Enabled = FalseTxtJariJari.SetFocusEnd Sub

Private Sub KeluarLingkaran()Pesan = MsgBox("Exit Form Luas Bangun Datar & Ruang ", vbQuestion + vbYesNo, "Konfirmasi")If Pesan = vbYes ThenMsgBox "Terima Kasih", vbInformation, "Informasi"EndElse If Pesan = vbNo Then MsgBox "Loh Kog Enggak Jadi!!!", vbOKOnly + 32, "Informasi" BersihLingkaran End IfEnd If End SubPrivate Sub CmdKeluarLingkaran_Click()KeluarLingkaranEnd Sub

Private Sub NonAktifSegitiga()TxtTinggi.Enabled = FalseTxtLSegitiga.Enabled = FalseCmdUlangSegitiga.Enabled = FalseCmdKeluarSegitiga.Enabled = FalseTxtAlas.SetFocusEnd Sub

Private Sub TxtAlas_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxtTinggi.Enabled = TrueTxtTinggi.SetFocusEnd IfEnd Sub

Private Sub TxtTinggi_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxtLSegitiga.Enabled = TrueTxtLSegitiga.Text = "Luas =" & " " & ((TxtAlas.Text * TxtTinggi.Text) / 2) & " " & "cm2"CmdUlangSegitiga.Enabled = TrueCmdKeluarSegitiga.Enabled = TrueCmdUlangSegitiga.SetFocusEnd IfEnd Sub

Private Sub BersihSegitiga()TxtAlas.Text = ""TxtTinggi.Text = ""TxtLSegitiga.Text = ""CmdUlangSegitiga.Enabled = FalseCmdKeluarSegitiga.Enabled = FalseTxtAlas.SetFocusEnd Sub

Private Sub CmdUlangSegitiga_Click()BersihSegitigaEnd SubPrivate Sub KeluarSegitiga()Pesan = MsgBox("Exit Form Luas Bangun Datar & Ruang ", vbQuestion + vbYesNo, "Konfirmasi")If Pesan = vbYes ThenMsgBox "Terima Kasih", vbInformation, "Informasi"EndElse If Pesan = vbNo Then MsgBox "Loh Kog Enggak Jadi!!!", vbOKOnly + 32, "Informasi" BersihSegitiga End IfEnd IfEnd Sub

Private Sub CmdKeluarSegitiga_Click()KeluarSegitigaEnd Sub

Program Mencari Nilai Huruf

Private Sub CmdBatal_Click()TxtAngka.Text = EmptyTxtHuruf.Text = EmptyCmdProses.Enabled = FalseCmdBatal.Enabled = FalseCmdKeluar.Enabled = TrueTxtAngka.SetFocusEnd Sub

Private Sub CmdKeluar_Click()Pesan = MsgBox("Exit Program ???", vbQuestion + vbYesNo, "Konfirmasi")If Pesan = vbYes ThenMsgBox "Terima Kasih", vbOKOnly, "Konfirmasi"EndElse If Pesan = vbNo Then MsgBox "Loh Kog Enggak Jadi", vbOKOnly, "Konfirmasi" End IfEnd IfEnd Sub

Private Sub CmdProses_Click()Dim Angka As IntegerDim Huruf As StringAngka = TxtAngka.Text

If (Angka >= 70) ThenHuruf = "LULUS"Else Huruf = "TIDAK LULUS"End IfTxtHuruf.Text = HurufCmdBatal.SetFocusEnd Sub

Private Sub Form_Activate()TxtHuruf.Enabled = FalseCmdProses.Enabled = FalseCmdBatal.Enabled = FalseCmdKeluar.Enabled = FalseTxtAngka.SetFocusEnd SubPrivate Sub TxtAngka_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxtHuruf.Enabled = TrueCmdProses.Enabled = TrueCmdBatal.Enabled = TrueCmdProses.SetFocusEnd IfEnd Sub

Program Kasir

Private Sub CboBanyak_Click()If CboBanyak.Text = "01" ThenTxtTotal.Text = CboBanyak.Text * TxtHarga.TextElseIf CboBanyak.Text = "02" ThenTxtTotal.Text = CboBanyak.Text * TxtHarga.TextElseIf CboBanyak.Text = "03" ThenTxtTotal.Text = CboBanyak.Text * TxtHarga.TextElseIf CboBanyak.Text = "04" ThenTxtTotal.Text = CboBanyak.Text * TxtHarga.TextElse TxtTotal.Text = CboBanyak.Text * TxtHarga.TextEnd IfTxtTotal.Enabled = 1TxtBayar.Enabled = 1TxtBayar.SetFocusEnd Sub

Private Sub CboKdBarang_Click()If CboKdBarang.Text = "KDOO1" ThenTxtNmBarang.Text = "Flash Disk"TxtHarga.Text = "50000"ElseIf CboKdBarang.Text = "KD002" ThenTxtNmBarang.Text = "Mouse"TxtHarga.Text = "65000"ElseIf CboKdBarang.Text = "KD003" ThenTxtNmBarang.Text = "Memory"TxtHarga.Text = "250000"ElseIf CboKdBarang.Text = "KD004" ThenTxtNmBarang.Text = "Harddisk"TxtHarga.Text = "500000"Else TxtNmBarang.Text = "Keyboard" TxtHarga.Text = "125000"End IfCboBanyak.Enabled = 1CboBanyak.SetFocusEnd Sub

Private Sub CmdBatal_Click()BatalEnd SubPrivate Sub Batal()CboKdBarang.Text = ""CboKdBarang.SetFocusTxtNmBarang.Text = ""TxtHarga.Text = ""CboBanyak.Text = ""TxtTotal.Text = ""TxtBayar.Text = ""TxtKembali.Text = ""NonAktifEnd Sub

Private Sub CmdKeluar_Click()pesan = MsgBox("Exit Program Kasir??", vbQuestion + vbYesNo, "Konfirmasi")If pesan = vbYes ThenMsgBox "Terima Kasih", vbOKOnly, "Konfirmasi"EndElse If pesan = vbNo Then MsgBox "Loh Kog Enggak jadi", vbInformation, "Informasi" End If BatalEnd IfEnd Sub

Private Sub Form_Activate()NonAktifEnd SubPrivate Sub NonAktif()CboBanyak.Enabled = 0TxtTotal.Enabled = 0TxtBayar.Enabled = 0TxtKembali.Enabled = 0CmdBatal.Enabled = 0CboKdBarang.SetFocusEnd Sub

Private Sub TxtBayar_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxtKembali.Text = TxtTotal.Text - TxtBayar.TextTxtKembali.Enabled = 1CmdBatal.Enabled = 1CmdBatal.SetFocusEnd IfEnd Sub

Program Mencari Nilai Pangkat Bilangan

Private Sub CmdHapus_Click()TxtNilai = EmptyTxtPangkat = EmptyTxtHasil = EmptyEnd Sub

Private Sub CmdProses_Click()Dim a As IntegerDim b As IntegerDim Jlh As Integera = Val(TxtNilai)b = Val(TxtPangkat)Jlh = 1For i = 1 To b Jlh = Jlh * aNext iTxtHasil.Text = JlhEnd Sub

Private Sub CmdTutup_Click()psn = MsgBox("Exit Program ???", 32 + 4, "Konfirmasi")If psn = vbYes ThenMsgBox "Terima Kasih Atas Kunjungan Anda", vbInformation, "informasi"End If psn = vbNo Then MsgBox "Loh Kok Enggak Jadi Yachhhh", vbCritical, "Pesan" End IfEnd IfEnd Sub

Private Sub TxtNilai_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxtPangkat.SetFocusEnd IfEnd SubPrivate Sub TxtPangkat_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenCmdProses.SetFocusEnd IfEnd Sub

Program Faktorial

Private Sub cmdHapus_Click()TxtFaktorial = ""TxtHasil = ""End Sub

Private Sub cmdTutup_Click()EndEnd Sub

Private Sub TxtFaktorial_KeyPress(KeyAscii As Integer)Dim a As LongDim Jlh As LongDim Hasil As Longa = Val(TxtFaktorial.Text)Jlh = 1If KeyAscii = 13 Then

If a