Tugas Mikroprosesor

 

Nama : Unggul Panji Dewanto

Nim    : 11.11.2586

Kelas  : TI 11 D

 

1. Pengertian Microcontroller

Microcontroller adalah sistem mikroprosesor lengkap yang terkandung di dalam sebuah chip. Microcontroler berbeda dari microprosesor serba guna yang digunakan dalam sebuah PC, karena di dalam sebuah microcontroler umumnya juga telah berisi komponen pendukung sistem minimal microprosesor, yakni memori dan antarmuka I/O, sedangkan di dalam microprosesor umumnya hanya berisi CPU saja.

2. Menyederhanakan Program
 

   

BASIC I/O P1 SEBAGAI OUTPUT

 

Langkah:

1.      Hubungkan PORT DT51 Min Sys dengan PORT OUTPUT DT-51 tariner board.

2.      Hubungkan CONTROL DT-51 Min Sys dengan CONTROL DT-51 trainer board.

3.      Hubungkan DT-51 Min Sys dengan PC menggunakan kabel serial

4.      Hubungkan Dt-51 MIn Sys dengan sumber tegangan

 

Program 4 Transfer data Output dari Data RAM

Data disimpan di RAM, kemudian satu persatu dikeluarkan ke P1

 

1.        Source Code yang masih lengkap

$mod51

     CSEG

     ORG   4000H

     LJMP  START

     ORG 4100H

START:    MOV 30H,#00000001B

MOV 31H,#00000010B

MOV 32H,#00000100B

MOV 33H,#00001000B

MOV 34H,#00010000B

MOV 35H,#00100000B

MOV 36H,#01000000B

MOV 37H,#10000000B

ULANG:   MOV P1,30H

                 MOV P1,31H

ACALL TUNDA

MOV P1,32H

ACALL TUNDA

                 MOV P1,33H

                 ACALL TUNDA

                 MOV P1,34H

                 ACALL TUNDA

                 MOV P1,35H

                 ACALL TUNDA

                 MOV P1,36H

                 ACALL TUNDA

                 MOV P1,37H

                 ACALL TUNDA

                 SJMP ULANG

TUNDA:   MOV R7,#0FFh

LAGI:      MOV R6,#0FFh

SINI:        DJNZ R6,SINI

                 DJNZ R7,LAGI

                 RET

END

2.        Setelah itu di modifikasi menjadi source code yang lebih singkat.

$mod51

                        ROM EQU 0000h

                        ORG ROM

                        LJMP MULAI

                        ORG ROM+0100

MULAI:   MOV A, #00000001b

NEXT:     MOV P1, A

                        ACALL TUNDA

                        RL A

                        CJNE A,#10000000b, NEXT

                        SJMP NEXT

TUNDA:  MOV R7,#03h

LUP1:      MOV R6,#0ffh

LUP2:      MOV R5,#0ffh

                        DJNZ R5,$

                        DJNZ R6,LUP2

DJNZ R7,LUP1

RET

END

LINK : 
http://khatirudinmaarif.blogspot.com/

http://vengeance16.blogspot.com/

 http://yudadayu.blogspot.com/

 http://ilmucomputer2512.blogspot.com

 http://hendraadiprasetyo.blogspot.com/

http://mreferensi.blogspot.com/

 http://cci-amikom.forumid.net/

 

 

Tugas 7 Navigator

Tugas VB

Navigator

 

Langkah – Langkah          :

  1. Buka SQL server,buat database baru

       2.Setelah database berhasil di buat,lalu buat table baru
          dengan format :

3

        3.Lalu simpan table,setelah itu isikan table

        4.buka Microsoft Visual Studio 2010,masukan source darii SQL server yang telah kita buat.

5

Klik Database

Klik Next

Klik Dataset

Klik Next pilih New Connection

Pilih Microsoft SQL Server, lalu Continue.

Lalu akan muncul jendela baru

6

5.masukan nama server SQL server,setelah selesai klik test connection Selanjutnya pilih Next, dan save.

6.Setelah itu maka akan muncul jendela baru

9

7.Centang table,klik finish

8.Buat form seperti berikut :

11

9.Berikut adalah listing program :

 

Untuk tombol pertama >

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        TbmahasiswaBindingSource.MoveFirst()

    End Sub

 

 

 

Untuk tombol sebelumnya >

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        TbmahasiswaBindingSource.MovePrevious()

    End Sub

Untuk tombol selanjutnya >

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        TbmahasiswaBindingSource.MoveNext()

    End Sub

Untuk tombol akhir >

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        TbmahasiswaBindingSource.MoveLast()

    End Sub

Untuk tombol tambah >

 Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

        TbmahasiswaBindingSource.AddNew()

    End Sub

Untuk tombol hapus >

  Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

        TbmahasiswaBindingSource.RemoveCurrent()

    End Sub

 

Untuk tombol simpan >

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

        Me.Validate()

        Me.TbmahasiswaBindingSource.EndEdit()

        Me.TableAdapterManager.UpdateAll(Me.TbmahasiswaDataSet1)

    End Sub

 

Untuk tombol cari >

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

        If (TbmahasiswaBindingSource.Find(“Nama”, TextBox1.Text)) > -1 Then

            MsgBox(“Data berhasil ditemukan”)

        Else

            MsgBox(“Data tidak berhasil ditemukan”)

        End If

 

    End Sub

 

Untuk tombol keluar > Me.Close()

 

 

Tugas 6 Function

Overloading Function

Adalah sebuah function dengan nama yang sama tetapi memiliki Parameter yang berbeda.

Untitled

Berikut Listing Programnya :

Public Class Form1

Function hitung(ByVal bil1 As Integer, ByVal bil2 As Integer) As Integer

hitung = bil1 * bil2

End Function

Function hitung(ByVal bil1 As Integer, ByVal bil2 As Integer, ByVal bil3 As Integer) As Integer

hitung = bil1 + bil2 + bil3

End Function

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

TextBox1.Text = hitung(3, 1, 2)

 

End Sub

End Class

 

Hasil Dari Listing Program Tersebut Adalah :

2

Penjelasanya     :

Program ini berjalan sesuai dengan function yang menggunakan penjumlahan 3 parameter (hitung = bil1 + bil2 + bil3) karena bilangan yang dimasukan di button 1 adalah 3 bilangan (TextBox1.Text = hitung(3, 1, 2)sehingga yang bekerja adalah function yang memiliki jumlah parameter yang sama dengan bilangan yang dimasukan dan function perkalian tidak bekerja atau diabaikan.

Kesimpulanya :

 

Program dapat bekerja dengan catatan parameter function memiliki jumlah yang sama dengan bilangan yang akan diicari.

 

Function dengan Return Value Berupa Array

3

Listing Programnya :

Public Class Form1

 

Private Function stats(ByVal ParamArray args() As Object) As Single()

Dim hasil(3) As Single

Dim i As Integer

For i = 0 To UBound(args)

hasil(0) = hasil(0) + args(i)

If i = 0 Then

hasil(1) = args(i)

hasil(2) = args(i)

 

End If

If hasil(1) > args(i) Then hasil(1) = args(i)

If hasil(2) < args(i) Then hasil(2) = args(i)

 

Next i

Return hasil

End Function

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim statistik As Single() = stats(1, 6, 2, 7, 3, 9, 4, 10, 8, 5)

TextBox1.Text = statistik(0)

TextBox2.Text = statistik(1)

TextBox3.Text = statistik(2)

 

End Sub

 

 

End Class

 

Hasil dari listing program diatas :

4

Penjelasanya     :

If hasil(1) > args(i) Then hasil(1) = args(i)

If hasil(2) < args(i) Then hasil(2) = args(i)

 

Listing diatas berfunsi untuk menentukan tebesar dan terkecil

 

Return hasil

Berfungsi untuk Pemanggilan hasil

TextBox1.Text = statistik(0)

TextBox2.Text = statistik(1)

TextBox3.Text = statistik(2)

 

Listing tersebut digunakan untuk pendeklarasian program untuk ditampilkan di textbox,sedangkan statistic digunakan untuk pemanggilan function

 

Macam –Macam Function Bawaan

Fungsi-fungsi Numerik

Dengan menggunakan fungsi-fungsi bawaan yang disediakan, waktu pembuatan sebuah program dapat disingkat. Fungsi-fungsi numerik merupakan fungsi-fungsi yang berkaitan dengan tipe data numerik.  Fungsi-fungsi ini dapat dikelompokkan sebagai berikut :

a.    Fungsi-fungsi konversi ke integer.

Ada tiga macam fungsi yang melakukan konversi ke tipe data integer  yaitu

  1. Cint() “Pembulatan nilai decimal 0,5 dan lebih ke integer yang lebih dekat”
  2. Fix()    “Pemotongan Suatu nilai decimal menjadi integer”
  3. Int()    “Pembulatan suatu nilai kebawah desimal ”

 

b.    Fungsi – fungsi konversi tipe data

5

c.    Fungsi-fungsi matematika

6

Fungsi – fungsi String

7

Substring merupakan bagian dari suatu string. Untuk memperoleh substring dari suatu string dapat digunakan 3 fungsi berikut :

  1. Left$(StringVal, length)

Fungsi ini mengembalikan nilai string dari sebelah kiri sebanyak length karakter .

  1. Right$(StringVal, length)

Fungsi ini mengembalikan nilai string dari sebelah kanan sebanyak length karakter .

  1. Mid$(StringVal, startVal, length)

Fungsi ini mengembalikan nilai string dari startVal sebanyak length karakter.

Fungsi-fungsi Tanggal dan Waktu

8

Fungsi Date and Time pada VB

 

Time : mencari tahu waktu saat ini atau menetapkan waktu, tergantung format

pemakaiannya ( lihat contoh di bawah ini)
A$ = Time ‘hasil 18:16:35 AM

MyTime = #4:35:17 PM# ‘assign a time
Time = MyTime ‘set system time to MyTime
Now : merekam tanggal dan waktu sekarang
A$ = Now ‘hasil 10/8/02 18:16:35 AM

Timer : menghitung jumlah detik sejak tengah malam
Start = Timer ‘hasilnya 29991

Date : menetapkan hari pada sistem komputer
Dim MyDate
MyDate = #February 12, 1985 # ‘Assign a date
Date = MyDate ‘Change system date
DateAdd : menghasilkan Varian(Date) yang berisi tanggal baru setelah suatu interval waktu yang ditetapkan dari tanggal lama.
DateAdd(kode_interval,jumlah_interval,tanggal_lama)

 

Contoh pemakaiannya :
Dim FirstDate As_Date ‘Declare variables
Dim IntervalType As String
Dim Number As Integer
Dim Msg
FirstDate = InputBox(“Enter a date”)
Bynber = InputBox(“Enter number of months to add”)
Msg = “New date : “ & DateAdd(“m”, Number, FirstDate)
MsgBox Msg

DateDiff : mencari interval waktu antara dua tanggal
DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]]) Dim TheDate As Date ‘declare variables
TheDate = InputBox(“Enter a date”) Msg = “Day from today : “ & DateDiff(“d”, Now, TheDate)
MsgBox Msg

DateSerial : menghasilkan tanggal dengan bulan/hari/tahun
MyDate = DateSerial(1969, 2, 12) ‘Hasil 2/12/69

 

DateValue : menghasilkan tanggal
MyDate = DateValue(“February 12, 1969”) ‘Hasil 2/12/69

Year : menghasilkan tahun sekarang
MyYear = Year(#2/12/1969#) ‘Hasil 1969

Month : menghasilkan bilangan integer yang menunjukkan bulan
MyDate = #February 12, 1969# ‘Assign a date
MyMonth = Month(MyDate) ‘MyMonth = 2

MonthName : menghasilkan teks yang menunjukkan nama bulan
a$ = MonthName(1, True) ‘a$ = Jan
b$ = MonthName(1, False) ‘b$ = January
c$ = MonthName(1) ‘c$ = January

Day : menghasilkan integer yang menunjukkan tanggal dari data date
MyDate = #February 12, 1969# ‘Assign a date
MyDay = Day(MyDate) ‘MyDay berisi 12

Hour : menghasilkan integer yang menunjukkan jam dari data timer
MyTime = #4:35:17 PM# ‘Assign a time
MyHour = Hour(MyTime) ‘MyHour berisi 16

Minute : menghasilkan integer yang menunjukkan menit dari data timer
MyTime = #4:35:17 PM# ‘Assign a time
MyMinute = Minute(MyTime) ‘MyMinute berisi 35

Second : menghasilkan integer yang menunjukkan detik dari data timer
MyTime = #4:35:17 PM# ‘Assign a time
MySecond = Second(MyTime) ‘MySecond berisi 17

TimeSerial : menghasilkan waktu dengan jam/menit/detik
MyTime = TimeSerial(16, 35, 17) ‘Isinya 4:35:17 PM

TimeValue : mengubah string waktu dari pukul 0:00:00 (12:00:00 AM) sampai 23:59:59 (11:59:59 PM) menjadi data waktu
MyTime = TimeValue(“4:35:17 PM”) ‘Isinya 4:35:17 PM
MyTime = TimeValue(“0:00:00”) ‘Isinya 12:00:00 AM

WeekDay : menghasilkan bilangan petunjuk hari dari suatu tanggal
Hari = #February 12, 1969# ‘Hari Rabu
MyweekDay = Weekday(Hari) ‘MyweekDay isinya 4

WeekDayName : menghasilkan teks nama hari dalam satu minggu

9

Tugas 5 MDI FORM

TUGAS MDI FORM

 

Desain Utama Form :

1

Di form utama dalam menu windows ditambahkan 3 sub menu yaitu Cascade,tile Horizontal,Tile Vetical :

2

Kemudia buat 2 form tambahan :

Untitled

Dengan coding :

PublicClassForm2

 

PrivateSub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load

Me.MdiParent = Form1

EndSub

EndClass

 

Untuk form 3 :

4

Dengan Coding :

PublicClassForm3

 

PrivateSub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load

Me.MdiParent = Form1

EndSub

EndClass

 

Berikut Coding Keseluruhan pada Form 1 :

PublicClassForm1

PrivateSub Tugas1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tugas1ToolStripMenuItem.Click

Me.LayoutMdi(MdiLayout.TileHorizontal)

Form2.Show()

Form3.Show()

EndSub

PrivateSub Latihan1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Latihan1ToolStripMenuItem.Click

Form2.MdiParent = Me

Form2.Show()

EndSub

PrivateSub Latihan2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Latihan2ToolStripMenuItem.Click

Me.LayoutMdi(MdiLayout.Cascade)

Form2.Show()

Form3.Show()

EndSub

PrivateSub CascadeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CascadeToolStripMenuItem.Click

Me.LayoutMdi(MdiLayout.Cascade)

Form2.Show()

Form3.Show()

EndSub

PrivateSub TileHorizontalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TileHorizontalToolStripMenuItem.Click

Me.LayoutMdi(Windows.Forms.MdiLayout.TileHorizontal)

Form2.Show()

Form3.Show()

EndSub

PrivateSub TileVerticalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TileVerticalToolStripMenuItem.Click

Me.LayoutMdi(MdiLayout.TileVertical)

Form2.Show()

Form3.Show()

EndSub

 

PrivateSub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click

Form2.MdiParent = Me

Form2.Show()

EndSub

PrivateSub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

Me.LayoutMdi(MdiLayout.TileVertical)

Form2.Show()

Form3.Show()

EndSub

PrivateSub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click

Me.Close()

EndSub

 

PrivateSub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click

Me.LayoutMdi(Windows.Forms.MdiLayout.TileHorizontal)

Form2.Show()

Form3.Show()

EndSub

EndClass

 

Berikut Program Ketika Di Run :

Cassade:

5

Tile Horizontal:

6

Tile Vertical :

7

Untuk Menu Ribbon ditambahkan dengan aplikasi penambah tool (DotNetBar)

8

Kumpulan Tugas

Tugas 1 :

https://updtkpj2.wordpress.com/2012/10/14/program-kasir-rental-kaset/

Tugas 2 :

https://updtkpj2.wordpress.com/2012/10/21/jawaban-tugas-2/

Tugas 3 :

https://updtkpj2.wordpress.com/2012/10/27/tugas-3-pemrograman-visual/

Tugas 4 :

https://updtkpj2.wordpress.com/2012/11/11/tugas-4-pemrograman-visual/

Tugas 5 :

https://updtkpj2.wordpress.com/2012/12/09/tugas-5-mdi-form/

Tugas 6 :

https://updtkpj2.wordpress.com/2012/12/23/tugas-6-function/

 

Tugas 4 Pemrograman Visual

Tugas Checkbox

Image

Berikut Listing Programnya :

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim control As Windows.Forms.CheckBox

        TextBox1.Text = “”

        For Each control In Me.GroupBox1.Controls

            If control.Checked = True Then

                TextBox1.Text &= control.Text & “,”

            End If

        Next

        TextBox1.Text = Microsoft.VisualBasic.Left(TextBox1.Text, Len(TextBox1.Text) – 1)

    End Sub

 

    Private Sub CheckBox7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox7.CheckedChanged

        Dim control As Windows.Forms.CheckBox

        TextBox1.Text = “”

    End Sub

End Class

 

Ketika Program di Jalankan :

Image

 

Tugas ListBox

Image

Berikut Listing Programnya :

ublic Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim control As Windows.Forms.ListBox

        TextBox1.Text = TextBox1.Text

        TextBox1.Text = ListBox1.Items.Add(TextBox1.Text)

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        For bil = 1 To 10

            ListBox1.Items.Add(bil)

        Next

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Satu.Click

        ListBox1.Text = ListBox2.Items.Add(ListBox1.Text)

    End Sub

 

    Private Sub Bt_Beberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Beberapa.Click

        ListBox1.SelectionMode = SelectionMode.MultiExtended

        Dim i, j As Integer

        j = ListBox1.Items.Count

        For i = 0 To j – 1

            Try

                ListBox2.Items.Add(ListBox1.Items(ListBox1.SelectedIndices(i)))

            Catch ex As Exception

                j -= 1

            End Try

        Next

    End Sub

 

    Private Sub Bt_Semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Semua.Click

        ListBox1.SelectionMode = SelectionMode.MultiExtended

 

        Dim Jumlah As Integer = ListBox1.Items.Count

 

        For i = 0 To Jumlah – 1

            ListBox2.Items.Add(ListBox1.Items(i))

        Next

    End Sub

 

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Hapus_Satu.Click

        ListBox2.SelectionMode = SelectionMode.One

 

        ListBox2.Items.Remove(ListBox2.SelectedItem)

    End Sub

 

    Private Sub Bt_Hapus_Beberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Hapus_Beberapa.Click

        ListBox2.SelectionMode = SelectionMode.MultiExtended

        Dim i, j As Integer

        j = ListBox2.Items.Count

        For i = 0 To j – 1

            Try

                ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)

            Catch ex As Exception

                j -= 1

            End Try

        Next

    End Sub

 

    Private Sub Bt_Hapus_Semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Hapus_Semua.Click

        ListBox2.Items.Clear()

    End Sub

 

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

        Me.Close()

    End Sub

End Class

 

Ketika Program Di Run :

Image

 

Tugas RadioButton

Image

Berikut Listing Programnya :

Public Class Form1

 

    Private Sub RbKawin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbKawin.CheckedChanged

        TextBox1.Text = “”

        If RbPria.Checked = True Then

        Else

            TextBox1.Text &= “Suami”

        End If

        If RbWanita.Checked = True Then

        Else

            TextBox1.Text &= “Istri”

        End If

    End Sub

  

    Private Sub RbTdkwin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbTdkwin.CheckedChanged

        TextBox1.Text = “”

        If RbPria.Checked = True Then

        Else

            TextBox1.Text &= “”

        End If

        If RbWanita.Checked = True Then

        Else

            TextBox1.Text &= “”

        End If

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.Close()

    End Sub

 

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

 

    End Sub

End Class

 

 

Ketika Program Di run :

Image

Image

 

Tugas 3 Pemrograman Visual

Program Penjualan Barang

List Program Setelah Di modifikasi :

Public Class Form1

    Private Sub cmbkode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbkode.SelectedIndexChanged

        Dim kdbarang, namabarang As String

        Dim harga As Single

        kdbarang = cmbkode.Text

        Select Case kdbarang

            Case “SPT”

                namabarang = “Sepatu”

                harga = 200000

            Case “SND”

                namabarang = “Sandal”

                harga = 100000

            Case “TST”

                namabarang = “T-Shirt”

                harga = 1500000

            Case “TOP”

                namabarang = “Topi”

                harga = 500000

            Case “TAS”

                namabarang = “TAS”

                harga = 250000

            Case Else

                namabarang = “-“

                harga = 0

        End Select

        txtnama.Text = namabarang

        txtharga.Text = harga

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim control As Windows.Forms.Control

        For Each control In Me.Controls

            control.Enabled = False

            btisidata.Enabled = True

            bttutup.Enabled = True

        Next

        cmbkode.Items.Add(“SPT”)

        cmbkode.Items.Add(“SND”)

        cmbkode.Items.Add(“TST”)

        cmbkode.Items.Add(“TOP”)

        cmbkode.Items.Add(“TAS”)

    End Sub

    Private Sub txtjumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtjumlah.TextChanged

        txttotal.Text = Val(txtharga.Text) * Val(txtjumlah.Text)

        txtbayar.Text = Val(txttotal.Text) – Val(txtdiskon.Text)

    End Sub

    Private Sub Radiotunai_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radiotunai.CheckedChanged

        txtdiskon.Text = Val(txttotal.Text) * 10 / 100

        txtbayar.Text = Val(txttotal.Text) – Val(txtdiskon.Text)

    End Sub

    Private Sub Radiokredit_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radiokredit.CheckedChanged

        txtdiskon.Text = 0

        txtbayar.Text = Val(txttotal.Text) – Val(txtdiskon.Text)

    End Sub

    Private Sub btclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btclear.Click

        Dim control As Windows.Forms.Control

        For Each control In Me.Controls

            control.Enabled = False

            btisidata.Enabled = True

            bttutup.Enabled = True

        Next

        txtbayar.Clear()

        txtdiskon.Clear()

        txtharga.Clear()

        txtjumlah.Clear()

        txtnama.Clear()

        txttotal.Clear()

        Me.Radiotunai.Checked = False

        Me.Radiokredit.Checked = False

        cmbkode.Text = “”

    End Sub

    Private Sub bttutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttutup.Click

        Me.Close()

    End Sub

    Private Sub btisidata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btisidata.Click

        Dim control As Windows.Forms.Control

        For Each control In Me.Controls

            control.Enabled = True

            btisidata.Enabled = False

        Next

    End Sub

End Class 

Program Pada Saat Di RUN :

Pada Saat Pertama Form Di jalankan :

Image

Pada Saat Tombol isi Data di klik

Image

 

Program Puzzle

 

Image

Normal
0

false
false
false

IN
X-NONE
X-NONE

MicrosoftInternetExplorer4

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,”sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:”Times New Roman”;
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:”Times New Roman”;
mso-bidi-theme-font:minor-bidi;}

Berikut adalah listing programnya :

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

        Dim control As Windows.Forms.Control

 

        For Each control In Me.Controls

 

            If control.GetType.Name = “Button” Then

 

                Dim rndnumber As Random

 

                Dim number As Integer

 

                rndnumber = New Random

 

                number = rndnumber.Next(1, 9)

 

                control.Text = number

 

 

 

                If Button2.Text = Button1.Text Then

 

                    Do

 

                        number = rndnumber.Next(1, 9)

 

                        Button2.Text = number

 

                    Loop Until Button2.Text <> Button1.Text

 

                End If

 

 

 

                If Button3.Text = Button2.Text Or Button3.Text = Button1.Text Then

 

                    Do

 

                        number = rndnumber.Next(1, 9)

 

                        Button3.Text = number

 

                    Loop Until Button3.Text <> Button2.Text And Button3.Text <> Button1.Text

 

                End If

 

 

 

                If Button4.Text = Button3.Text Or Button4.Text = Button2.Text Or Button4.Text = Button1.Text Then

 

                    Do

 

                        number = rndnumber.Next(1, 9)

 

                        Button4.Text = number

 

                    Loop Until Button4.Text <> Button3.Text And Button4.Text <> Button2.Text And Button4.Text <> Button1.Text

 

                End If

 

 

 

                If Button4.Text = Button3.Text Or Button4.Text = Button2.Text Or Button4.Text = Button1.Text Then

 

                    Do

 

                        number = rndnumber.Next(1, 9)

 

                        Button4.Text = number

 

                    Loop Until Button4.Text <> Button3.Text And Button4.Text <> Button2.Text And Button4.Text <> Button1.Text

 

                End If

 

 

 

                If Button5.Text = Button4.Text Or Button5.Text = Button3.Text Or Button5.Text = Button2.Text Or Button5.Text = Button1.Text Then

 

                    Do

 

                        number = rndnumber.Next(1, 9)

 

                        Button5.Text = number

 

                    Loop Until Button5.Text <> Button4.Text And Button5.Text <> Button3.Text And Button5.Text <> Button2.Text And Button5.Text <> Button1.Text

 

                End If

 

 

 

                If Button6.Text = Button5.Text Or Button6.Text = Button4.Text Or Button6.Text = Button3.Text Or Button6.Text = Button2.Text Or Button6.Text = Button1.Text Then

 

                    Do

 

                        number = rndnumber.Next(1, 9)

 

                        Button6.Text = number

 

                    Loop Until Button6.Text <> Button5.Text And Button6.Text <> Button3.Text And Button6.Text <> Button2.Text And Button6.Text <> Button1.Text

 

                End If

 

 

 

                If Button7.Text = Button6.Text Or Button7.Text = Button5.Text Or Button7.Text = Button4.Text Or Button7.Text = Button3.Text Or Button7.Text = Button2.Text Or Button7.Text = Button1.Text Then

 

                    Do

 

                        number = rndnumber.Next(1, 9)

 

                        Button7.Text = number

 

                    Loop Until Button7.Text <> Button6.Text And Button7.Text <> Button5.Text And Button7.Text <> Button4.Text And Button7.Text <> Button3.Text And Button7.Text <> Button2.Text And Button7.Text <> Button1.Text

 

                End If

 

 

 

                If Button8.Text = Button7.Text Or Button8.Text = Button6.Text Or Button8.Text = Button5.Text Or Button8.Text = Button4.Text Or Button8.Text = Button3.Text Or Button8.Text = Button2.Text Or Button8.Text = Button1.Text Then

 

                    Do

 

                        number = rndnumber.Next(1, 9)

 

                        Button8.Text = number

 

                    Loop Until Button8.Text <> Button7.Text And Button8.Text <> Button6.Text And Button8.Text <> Button5.Text And Button8.Text <> Button4.Text And Button8.Text <> Button3.Text And Button8.Text <> Button2.Text And Button8.Text <> Button1.Text

 

                End If

 

            End If

 

            Button9.Text = “”

 

        Next

 

    End Sub

 

 

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        If Button2.Text = “” Then

 

            Button2.Text = Button1.Text

 

            Button1.Text = “”

 

        ElseIf Button4.Text = “” Then

 

            Button4.Text = Button1.Text

 

            Button1.Text = “”

 

        End If

 

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

 

            MsgBox(“Selamat Anda Menang”)

 

        End If

 

    End Sub

 

 

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

 

        If Button1.Text = “” Then

 

            Button1.Text = Button2.Text

 

            Button2.Text = “”

 

        ElseIf Button3.Text = “” Then

 

            Button3.Text = Button2.Text

 

            Button2.Text = “”

 

        ElseIf Button5.Text = “” Then

 

            Button5.Text = Button2.Text

 

            Button2.Text = “”

 

        End If

 

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

 

            MsgBox(“Selamat Anda Menang”)

 

        End If

 

    End Sub

 

 

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

 

        If Button2.Text = “” Then

 

            Button2.Text = Button3.Text

 

            Button3.Text = “”

 

        ElseIf Button6.Text = “” Then

 

            Button6.Text = Button3.Text

 

            Button3.Text = “”

 

        End If

 

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

 

            MsgBox(“Selamat Anda Menang”)

 

        End If

 

    End Sub

 

 

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

 

        If Button1.Text = “” Then

 

            Button1.Text = Button4.Text

 

            Button4.Text = “”

 

        ElseIf Button7.Text = “” Then

 

            Button7.Text = Button4.Text

 

            Button4.Text = “”

 

        ElseIf Button5.Text = “” Then

 

            Button5.Text = Button4.Text

 

            Button4.Text = “”

 

        End If

 

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

 

            MsgBox(“Selamat Anda Menang”)

 

        End If

 

    End Sub

 

 

 

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

 

        If Button2.Text = “” Then

 

            Button2.Text = Button5.Text

 

            Button5.Text = “”

 

        ElseIf Button4.Text = “” Then

 

            Button4.Text = Button5.Text

 

            Button5.Text = “”

 

        ElseIf Button6.Text = “” Then

 

            Button6.Text = Button5.Text

 

            Button5.Text = “”

 

        ElseIf Button8.Text = “” Then

 

            Button8.Text = Button5.Text

 

            Button5.Text = “”

 

        End If

 

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

 

            MsgBox(“Selamat Anda Menang”)

 

        End If

 

    End Sub

 

 

 

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

 

        If Button9.Text = “” Then

 

            Button9.Text = Button6.Text

 

            Button6.Text = “”

 

        ElseIf Button3.Text = “” Then

 

            Button3.Text = Button6.Text

 

            Button6.Text = “”

 

        ElseIf Button5.Text = “” Then

 

            Button5.Text = Button6.Text

 

            Button6.Text = “”

 

        End If

 

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

 

            MsgBox(“Selamat Anda Menang”)

 

        End If

 

    End Sub

 

 

 

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

 

        If Button4.Text = “” Then

 

            Button4.Text = Button7.Text

 

            Button7.Text = “”

 

        ElseIf Button8.Text = “” Then

 

            Button8.Text = Button7.Text

 

            Button7.Text = “”

 

        End If

 

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

 

            MsgBox(“Selamat Anda Menang”)

 

        End If

 

    End Sub

 

 

 

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

 

        If Button7.Text = “” Then

 

            Button7.Text = Button8.Text

 

            Button8.Text = “”

 

        ElseIf Button9.Text = “” Then

 

            Button9.Text = Button8.Text

 

            Button8.Text = “”

 

        ElseIf Button5.Text = “” Then

 

            Button5.Text = Button8.Text

 

            Button8.Text = “”

 

        End If

 

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

 

            MsgBox(“Selamat Anda Menang”)

 

        End If

 

    End Sub

 

 

 

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

 

        If Button6.Text = “” Then

 

            Button6.Text = Button9.Text

 

            Button9.Text = “”

 

        ElseIf Button8.Text = “” Then

 

            Button8.Text = Button9.Text

 

            Button9.Text = “”

 

        End If

 

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

 

            MsgBox(“Selamat Anda Menang”)

 

        End If

 

    End Sub

 

End Class

 

 

 

 

 

Berikut Saat Program dijalankan :

Image

Image

 

Normal
0

false
false
false

IN
X-NONE
X-NONE

MicrosoftInternetExplorer4

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,”sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:”Times New Roman”;
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:”Times New Roman”;
mso-bidi-theme-font:minor-bidi;}

Berikut adalah listing programnya :

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim control As Windows.Forms.Control

        For Each control In Me.Controls

            If control.GetType.Name = “Button” Then

                Dim rndnumber As Random

                Dim number As Integer

                rndnumber = New Random

                number = rndnumber.Next(1, 9)

                control.Text = number

 

                If Button2.Text = Button1.Text Then

                    Do

                        number = rndnumber.Next(1, 9)

                        Button2.Text = number

                    Loop Until Button2.Text <> Button1.Text

                End If

 

                If Button3.Text = Button2.Text Or Button3.Text = Button1.Text Then

                    Do

                        number = rndnumber.Next(1, 9)

                        Button3.Text = number

                    Loop Until Button3.Text <> Button2.Text And Button3.Text <> Button1.Text

                End If

 

                If Button4.Text = Button3.Text Or Button4.Text = Button2.Text Or Button4.Text = Button1.Text Then

                    Do

                        number = rndnumber.Next(1, 9)

                        Button4.Text = number

                    Loop Until Button4.Text <> Button3.Text And Button4.Text <> Button2.Text And Button4.Text <> Button1.Text

                End If

 

                If Button4.Text = Button3.Text Or Button4.Text = Button2.Text Or Button4.Text = Button1.Text Then

                    Do

                        number = rndnumber.Next(1, 9)

                        Button4.Text = number

                    Loop Until Button4.Text <> Button3.Text And Button4.Text <> Button2.Text And Button4.Text <> Button1.Text

                End If

 

                If Button5.Text = Button4.Text Or Button5.Text = Button3.Text Or Button5.Text = Button2.Text Or Button5.Text = Button1.Text Then

                    Do

                        number = rndnumber.Next(1, 9)

                        Button5.Text = number

                    Loop Until Button5.Text <> Button4.Text And Button5.Text <> Button3.Text And Button5.Text <> Button2.Text And Button5.Text <> Button1.Text

                End If

 

                If Button6.Text = Button5.Text Or Button6.Text = Button4.Text Or Button6.Text = Button3.Text Or Button6.Text = Button2.Text Or Button6.Text = Button1.Text Then

                    Do

                        number = rndnumber.Next(1, 9)

                        Button6.Text = number

                    Loop Until Button6.Text <> Button5.Text And Button6.Text <> Button3.Text And Button6.Text <> Button2.Text And Button6.Text <> Button1.Text

                End If

 

                If Button7.Text = Button6.Text Or Button7.Text = Button5.Text Or Button7.Text = Button4.Text Or Button7.Text = Button3.Text Or Button7.Text = Button2.Text Or Button7.Text = Button1.Text Then

                    Do

                        number = rndnumber.Next(1, 9)

                        Button7.Text = number

                    Loop Until Button7.Text <> Button6.Text And Button7.Text <> Button5.Text And Button7.Text <> Button4.Text And Button7.Text <> Button3.Text And Button7.Text <> Button2.Text And Button7.Text <> Button1.Text

                End If

 

                If Button8.Text = Button7.Text Or Button8.Text = Button6.Text Or Button8.Text = Button5.Text Or Button8.Text = Button4.Text Or Button8.Text = Button3.Text Or Button8.Text = Button2.Text Or Button8.Text = Button1.Text Then

                    Do

                        number = rndnumber.Next(1, 9)

                        Button8.Text = number

                    Loop Until Button8.Text <> Button7.Text And Button8.Text <> Button6.Text And Button8.Text <> Button5.Text And Button8.Text <> Button4.Text And Button8.Text <> Button3.Text And Button8.Text <> Button2.Text And Button8.Text <> Button1.Text

                End If

            End If

            Button9.Text = “”

        Next

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If Button2.Text = “” Then

            Button2.Text = Button1.Text

            Button1.Text = “”

        ElseIf Button4.Text = “” Then

            Button4.Text = Button1.Text

            Button1.Text = “”

        End If

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

            MsgBox(“Selamat Anda Menang”)

        End If

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        If Button1.Text = “” Then

            Button1.Text = Button2.Text

            Button2.Text = “”

        ElseIf Button3.Text = “” Then

            Button3.Text = Button2.Text

            Button2.Text = “”

        ElseIf Button5.Text = “” Then

            Button5.Text = Button2.Text

            Button2.Text = “”

        End If

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

            MsgBox(“Selamat Anda Menang”)

        End If

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        If Button2.Text = “” Then

            Button2.Text = Button3.Text

            Button3.Text = “”

        ElseIf Button6.Text = “” Then

            Button6.Text = Button3.Text

            Button3.Text = “”

        End If

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

            MsgBox(“Selamat Anda Menang”)

        End If

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        If Button1.Text = “” Then

            Button1.Text = Button4.Text

            Button4.Text = “”

        ElseIf Button7.Text = “” Then

            Button7.Text = Button4.Text

            Button4.Text = “”

        ElseIf Button5.Text = “” Then

            Button5.Text = Button4.Text

            Button4.Text = “”

        End If

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

            MsgBox(“Selamat Anda Menang”)

        End If

    End Sub

 

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

        If Button2.Text = “” Then

            Button2.Text = Button5.Text

            Button5.Text = “”

        ElseIf Button4.Text = “” Then

            Button4.Text = Button5.Text

            Button5.Text = “”

        ElseIf Button6.Text = “” Then

            Button6.Text = Button5.Text

            Button5.Text = “”

        ElseIf Button8.Text = “” Then

            Button8.Text = Button5.Text

            Button5.Text = “”

        End If

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

            MsgBox(“Selamat Anda Menang”)

        End If

    End Sub

 

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

        If Button9.Text = “” Then

            Button9.Text = Button6.Text

            Button6.Text = “”

        ElseIf Button3.Text = “” Then

            Button3.Text = Button6.Text

            Button6.Text = “”

        ElseIf Button5.Text = “” Then

            Button5.Text = Button6.Text

            Button6.Text = “”

        End If

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

            MsgBox(“Selamat Anda Menang”)

        End If

    End Sub

 

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

        If Button4.Text = “” Then

            Button4.Text = Button7.Text

            Button7.Text = “”

        ElseIf Button8.Text = “” Then

            Button8.Text = Button7.Text

            Button7.Text = “”

        End If

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

            MsgBox(“Selamat Anda Menang”)

        End If

    End Sub

 

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

        If Button7.Text = “” Then

            Button7.Text = Button8.Text

            Button8.Text = “”

        ElseIf Button9.Text = “” Then

            Button9.Text = Button8.Text

            Button8.Text = “”

        ElseIf Button5.Text = “” Then

            Button5.Text = Button8.Text

            Button8.Text = “”

        End If

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

            MsgBox(“Selamat Anda Menang”)

        End If

    End Sub

 

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

        If Button6.Text = “” Then

            Button6.Text = Button9.Text

            Button9.Text = “”

        ElseIf Button8.Text = “” Then

            Button8.Text = Button9.Text

            Button9.Text = “”

        End If

        If Button1.Text = “1” And Button2.Text = “2” And Button3.Text = “3” And Button4.Text = “4” And Button5.Text = “5” And Button6.Text = “6” And Button7.Text = “7” And Button8.Text = “8” And Button9.Text = “” Then

            MsgBox(“Selamat Anda Menang”)

        End If

    End Sub

End Class

 

 

Berikut Saat Program dijalankan :

Jawaban Tugas 2

Jawaban Latihan 1 Nomor 3 :

 

  1. nama belum di deklarasikan pada method di dalam class tersebut, di btalamat1_Click hanya tertulis :
    alamat = “Kuningan”
    Txtalamat.Text = alamat
    seharusnya adalah :
    Dim alamat As String
    alamat = “Kuningan”
    Txtalamat.Text = alamat
  2. Karena Pada tombol nama1 pendeklarasian nama sudah di masukan Dim nama As String

Nama = “Nandang” sedangkan pada tombol nama2, nama belum di deklarasikan sehingga sehingga mengambil dari module

Pada Btalamat 1 dan tombol alamat

2 sudah di deklarasikan di form

1        dengan Conts alamat = “kuningan”

 

c.Karena pada tombol tambah umur1 menggunakan dim yaitu masukan selalu memulai          kembali jika tombol di tekan sedangkan pada tombol tambah umur2 menggunakan static yaitu masukan yang tetap dan bertambah jika di tekan karna static dan umur +=1

 

d. Option Explicit Off
    Itu artinya bahwa variabel pada FrmDua tidak perlu kita definisikan dan program akan       langsung mengambil definisi variabel-variabel itu dari variabel Public yang terdapat dimanapun. Pada program ini variabel-variable tersebtu terdapat pada Module1. Sehingga pada saat kita menekan tombol Nama atau Alamat atau Umur, nilai yang keluar adalah nilai yang terdapat pada Module1.

 

Latihan 2

 

 

 

 

 

 

 

Tambahan Listing Program Tas

 

 

 

 

 

 

 

 

 

 

 

  1. Isikan perintah atau coding pada masing-masing button, combobox, radio button

Public Class Form1

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        cmbcode.Items.Add(“SPT”)

        cmbcode.Items.Add(“SND”)

        cmbcode.Items.Add(“TST”)

        cmbcode.Items.Add(“TOP”)

        cmbcode.Items.Add(“TAS”)

    End Sub

 

    Private Sub cmbcode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbcode.SelectedIndexChanged

        Dim kdbarang, namabarang As String

        Dim harga As Single

        kdbarang = cmbcode.Text

        Select Case kdbarang

            Case “SPT”

                namabarang = “Sepatu”

                harga = 200000

            Case “SND”

                namabarang = “Sandal”

                harga = 100000

            Case “TST”

                namabarang = “T-Shirt”

                harga = 150000

            Case “TOP”

                namabarang = “Topi”

                harga = 500000

Case “TAS”

                namabarang = “Tas”

                harga = 250000

 

            Case Else

                namabarang = “-“

                harga = 0

        End Select

        txtnama.Text = namabarang

        txtharga.Text = harga

    End Sub

 

    Private Sub txtjumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtjumlah.TextChanged

        txttotal.Text = Val(txtharga.Text) * Val(txtjumlah.Text)

        txtbayar.Text = Val(txttotal.Text) – Val(txtdiskon.Text)

    End Sub

 

    Private Sub radiotunai_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radiotunai.CheckedChanged

        txtdiskon.Text = Val(txttotal.Text) * 10 / 100

        txtbayar.Text = Val(txttotal.Text) – Val(txtdiskon.Text)

    End Sub

 

    Private Sub radiokredit_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radiokredit.CheckedChanged

        txtdiskon.Text = 0

        txtbayar.Text = Val(txttotal.Text) – Val(txtdiskon.Text)

    End Sub

 

    Private Sub btclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btclear.Click

        txtbayar.Clear()

        txtdiskon.Clear()

        txtharga.Clear()

        txtjumlah.Clear()

        txtnama.Clear()

        txttotal.Clear()

        txtuangbayar.Clear()

        txtuangkembali.Clear()

        Me.radiotunai.Checked = False

        Me.radiokredit.Checked = False

        cmbcode.Text = “”

    End Sub

 

    Private Sub bttutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttutup.Click

        Me.Close()

    End Sub

 

    Private Sub btkembalian_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btkembalian.Click

        If txtuangbayar.Text = “” Then

            MessageBox.Show(txtuangbayar, “Maaf Anda Belum Memasukkan Uang Bayar”)

        ElseIf txtuangbayar.Text < txtbayar.Text Then

            MessageBox.Show(txtuangbayar, “Maaf Uang Anda Kurang”)

        ElseIf txtuangbayar.Text > txtbayar.Text Then

            txtuangkembali.Text = txtuangbayar.Text – txtbayar.Text

        End If

 

    End Sub

End Class

 

 

 Image

Program Kasir Rental Kaset

source kodenya

(Name) combo box diganti dengan Ckode

(Name)Text Box diganti dengan Txthrg

Private Sub Ckode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ckode.SelectedIndexChanged

If Ckode.Text = “CD” Then

Txthrg.Text = “2000”

ElseIf Ckode.Text = “DVD” Then

Txthrg.Text = “4000”

Else : Txthrg.Text = “”

End If

End Sub

1.(Name) Text Box diganti dengan Txtjdl

2.(Name) Text Box diganti Dengan Txtjml

3.(Name) Text box Diganti Dengan Txttgl

4.(Name) Text box Diganti Dengan Txtbyr

5.(Name) Button Diganti Dengan pinjam

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pinjam.Click

Txtbyr.Text = Txthrg.Text * Txtjml.Text

MsgBox(“Judul Kaset :” & Txtjdl.Text & vbNewLine &

“Kaset :” & Ckode.Text & vbNewLine &

“Harga Per Disk :” & Txthrg.Text & vbNewLine &

“Jumlah kaset :” & Txtjml.Text & vbNewLine &

“Tgl Pnjam :” & Txttgl.Text & vbNewLine &

“Total Yang Harus Di Bayar :” & Txtbyr.Text & vbNewLine)

If Txtbyr.Text >= 10000 And Txtbyr.Text < 15000 Then

MsgBox(“Diskon = 2000 ” & vbOKOnly & vbNewLine &

“Yang Harus Dibayar:” & Txtbyr.Text – 2000)

ElseIf Txtbyr.Text >= 15000 And Txtbyr.Text < 20000 Then

MsgBox(“Diskon = 4000 ” & vbOKOnly & vbNewLine &

“Yang Harus DiBayar:” & Txtbyr.Text – 4000)

ElseIf Txtbyr.Text >= 20000 Then

MsgBox(“Diskon = 6000” & vbOKOnly & vbNewLine &

“yang Harus Dibayar:” & Txtbyr.Text – 6000)

End If

End Sub

(Name) Button Diganti Dengan hapus

Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus.Click

Txtjdl.Clear()

Txtjml.Clear()

Txttgl.Clear()

Txthrg.Clear()

Txtbyr.Clear()

End Sub

(Name) text box pada judul kaset diganti dengan Pjdl

(Name) text box pada Tgl Pinjam diganti dengan Ptlgp

(Name) text bok padaa Tgl Kembali diganti dengan Ptlgk

(Name) Raadio button telat Diganti dengan t

(Name) Radio Button Pada 1 minggu diganti dengan k1

(Name) Radio Button Pada 2 minggu diganti dengan k2

(Name) Radio Button Pada 3 minggu diganti dengan k3

(Name) Radio Button Pada 1 Bulan Lebih diganti dengan k4

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pengembalian.Click

MsgBox(“Judul Kaset   :” & Pjdl.Text & vbNewLine &

“Tgl pinjam    :” & Ptglp.Text & vbNewLine &

“Tgl Kembali  :” & Ptglk.Text & vbNewLine)

If t.Checked And k1.Checked = True Then

MsgBox(“Denda : 2000”)

ElseIf t.Checked And k2.Checked = True Then

MsgBox(“Denda : 4000”)

ElseIf t.Checked And k3.Checked = True Then

MsgBox(“Denda : 6000”)

ElseIf t.Checked And k4.Checked = True Then

MsgBox(“Denda : 10000 & Pencabutan Member”)

End If

End Sub

Running Program