Visual Basic Lanjutan Praktikum 4 - Array Dimensi Dua


Laptopinformatika.com - Array merupakan tipe data terstruktur yang terdiri dari sejumlah komponen yang memiliki tipe data yang samaArray merupakan konsep yang penting dalam
pemrograman, karena array memungkinkan untuk menyimpan data maupun referensi objek
dalam jumlah banyak dan terindeks
. Banyaknya komponen dalam suatu array ditunjukkan oleh suatu indeks yang disebut dengan Tipe Indeks (Index Type).


Untuk Latihan-latihan sebelumnya ada di link bawah ini, jika kalian ingin mempelajari semuanya silahkan klik link di bawah ini :

  1. Visual Basic Lanjutan Teori 1 Variabel dan Type Data
  2. Visual Basic Lanjutan Praktikum 1 Operator
  3. Visual Basic Lanjutan Teori 2 Percabangan (Struktur If-Then, If-Then-Else, Nested IF)
  4. Visual Basic Lanjutan Praktikum 2 Percabangan (IIF dan Select Case)
  5. Visual Basic Lanjutan Teori 3 - Perulangan
  6. Visual Basic Lanjutan Praktikum 3 - Perulangan (Do While - Loop)
  7. Visual Basic Lanjutan Teori 4 - Array Dimensi Satu

Array Dimensi Dua


  • Suatu array yang fungsinya hampir sama dengan array satu dimensi.
  • Hanya saja pada array dimensi dua ini mewakili nilai-nilai tabel yang terdiri dari informasi yang diatur dalam baris dan kolom.
  • Untuk mengidentifikasi elemen-elemen tabel tertentu.
  • harus menentukan dua indeks.
  • Pertama untuk mengidentifikasi elemen baris dan yang kedua mengidentifikasi elemen-elemen
    kolom
    .
  • Array multidimensi memiliki lebih dari dua dimensi.
Aturan penulisan Array Multidimensi: 
  • Dim nama_array [indeks baris, indeks kolom] As Tipe_Data.
     

Latihan 1


  • Source Code

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "LaptopInformatika.com"
        Dim arr(3, 1) As String
        arr(0, 0) = "Nim"
        arr(0, 1) = "Nama"
        arr(1, 0) = "Jenis Kelamin" 'laptopinformatika.com
        arr(1, 1) = "Status"
        arr(2, 0) = "Pria"
        arr(2, 1) = "Wanita"
        arr(3, 0) = "Menikah"
        arr(3, 1) = "Lajang"
        ListView1.GridLines = True
        ListView1.View = View.Details
        For baris = 0 To 1
            For kolom = 0 To 1
                ListView1.Columns.Add(arr(baris, kolom), 100) 'laptopinformatika.com
            Next
        Next
        For baris = 2 To 2
            For kolom = 0 To 1
                ComboBox1.Items.Add(arr(baris, kolom))
            Next
        Next
        For baris = 3 To 3
            For kolom = 0 To 1
                ComboBox2.Items.Add(arr(baris, kolom)) 'laptopinformatika.com
            Next
        Next
        TextBox1.ReadOnly = True
        TextBox1.Text = "1"
        TextBox2.Focus()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim arr(4) As String
        arr(0) = TextBox1.Text
        arr(1) = TextBox2.Text
        arr(2) = ComboBox1.Text
        arr(3) = ComboBox2.Text
        Dim list As New ListViewItem
        list = ListView1.Items.Add(arr(0)) 'laptopinformatika.com
        list.SubItems.Add(arr(1))
        list.SubItems.Add(arr(2))
        list.SubItems.Add(arr(3))
        TextBox1.Text = TextBox1.Text + 1
        TextBox2.Text = ""
        ComboBox1.Text = ""
        ComboBox2.Text = ""
        TextBox2.Focus()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim pesan As String
        pesan = MsgBox("Are you sure want to exit", vbYesNo, "laptopinformatika.com")
        If pesan = vbYes Then
            End
        End If
    End Sub
End Class

Latihan 2

  • Source Code
Public Class Form2

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "LaptopInformatika.com"
        Dim arr(4, 1) As String
        arr(0, 0) = "ID"
        arr(0, 1) = "NAMA"
        arr(1, 0) = "JENIS KELAMIN"
        arr(1, 1) = "JABATAN"
        arr(2, 0) = "ALAMAT"
        arr(2, 1) = "TGL LAHIR"
        arr(3, 0) = "TELP"
        arr(3, 1) = "EMAIL"
        arr(4, 0) = "PRIA"
        arr(4, 1) = "WANITA"
        ListView1.GridLines = True
        ListView1.View = View.Details
        For baris = 0 To 1
            For kolom = 0 To 1
                ListView1.Columns.Add(arr(baris, kolom), 100)
            Next kolom
        Next baris
        For baris = 4 To 4
            For kolom = 0 To 1
                ComboBox1.Items.Add(arr(baris, kolom))
            Next kolom
        Next baris
        ListView1.Columns.Add("ALAMAT", 125)
        ListView1.Columns.Add("TANGGAL LAHIR", 105)
        ListView1.Columns.Add("TELP", 105)
        ListView1.Columns.Add("EMAIL", 110)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim arr(7) As String
        arr(0) = TextBox1.Text 'laptopinformatika.com
        arr(1) = TextBox2.Text
        arr(2) = ComboBox1.Text
        arr(3) = TextBox3.Text
        arr(4) = TextBox4.Text
        arr(5) = TextBox5.Text
        arr(6) = TextBox6.Text
        arr(7) = TextBox7.Text
        Dim listitem As ListViewItem
        listitem = New ListViewItem
        listitem = ListView1.Items.Add(arr(0)) 'laptopinformatika.com
        listitem.SubItems.Add(arr(1))
        listitem.SubItems.Add(arr(2))
        listitem.SubItems.Add(arr(3))
        listitem.SubItems.Add(arr(4))
        listitem.SubItems.Add(arr(5))
        listitem.SubItems.Add(arr(6))
        listitem.SubItems.Add(arr(7)) 'laptopinformatika.com
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        ComboBox1.Text = "" 'laptopinformatika.com
        TextBox1.Focus()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim pesan As String
        pesan = MsgBox("Are you sure want to exit", vbYesNo, "laptopinformatika.com")
        If pesan = vbYes Then
            End
        End If
    End Sub
End Class

Latihan 3

  • Source Code
Public Class Form3

    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "LaptopInformatika.com"
        TextBox2.Focus()
        Dim arr(1, 2) As String
        arr(0, 0) = "NIS"
        arr(0, 1) = "NAMA"
        arr(0, 2) = "JUMLAH"
        arr(1, 0) = "RATA-RATA"
        arr(1, 1) = "GRADE"
        arr(1, 2) = "KETERANGAN"
        ListView1.GridLines = True
        ListView1.View = View.Details
        For baris = 0 To 1
            For kolom = 0 To 2
                ListView1.Columns.Add(arr(baris, kolom), 85) 'laptopinformatika.com
            Next
        Next
        TextBox1.ReadOnly = True
        TextBox1.Text = "2017230"
    End Sub

    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
        TextBox6.Text = Val(TextBox3.Text) + Val(TextBox4.Text) + Val(TextBox5.Text) 'laptopinformatika.com
        TextBox7.Text = FormatNumber((TextBox6.Text) / 3)
    End Sub

    Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
        TextBox6.Text = Val(TextBox3.Text) + Val(TextBox4.Text) + Val(TextBox5.Text) 'laptopinformatika.com
        TextBox7.Text = FormatNumber((TextBox6.Text) / 3)
    End Sub

    Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
        TextBox6.Text = Val(TextBox3.Text) + Val(TextBox4.Text) + Val(TextBox5.Text) 'laptopinformatika.com
        TextBox7.Text = FormatNumber((TextBox6.Text) / 3)
    End Sub

    Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged
        If TextBox7.Text >= 90 Then
            TextBox8.Text = "A"
        ElseIf TextBox7.Text >= 80 Then
            TextBox8.Text = "B"
        ElseIf TextBox7.Text >= 70 Then
            TextBox8.Text = "C"
        ElseIf TextBox7.Text < 70 Then 'laptopinformatika.com
            TextBox8.Text = "D"
        End If
    End Sub

    Private Sub TextBox8_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged
        If TextBox8.Text = "A" Then
            TextBox9.Text = "LULUS"
        ElseIf TextBox8.Text = "B" Then
            TextBox9.Text = "LULUS"
        ElseIf TextBox8.Text = "C" Then
            TextBox9.Text = "LULUS"
        Else
            TextBox9.Text = "BELUM LULUS" 'laptopinformatika.com
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim arr(5) As String
        arr(0) = TextBox1.Text
        arr(1) = TextBox2.Text
        arr(2) = TextBox6.Text
        arr(3) = TextBox7.Text
        arr(4) = TextBox8.Text
        arr(5) = TextBox9.Text
        Dim list As New ListViewItem
        list = ListView1.Items.Add(arr(0)) 'laptopinformatika.com
        list.SubItems.Add(arr(1))
        list.SubItems.Add(arr(2))
        list.SubItems.Add(arr(3))
        list.SubItems.Add(arr(4))
        list.SubItems.Add(arr(5))
        TextBox1.Text = Val(TextBox1.Text) + 1 'laptopinformatika.com
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        TextBox2.Focus()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim pesan As String
        pesan = MsgBox("Are you sure want to exit", vbYesNo, "laptopinformatika.com")
        If pesan = vbYes Then
            End
        End If
    End Sub
End Class

Kasus 1

  • Source Code
Public Class Form4

    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "LaptopInformatika.com"
        Dim arr(3, 1) As String
        arr(0, 0) = "Makanan/Minuman"
        arr(0, 1) = "Harga"
        arr(1, 0) = "Stok" 'laptopinformatika.com
        arr(1, 1) = "Jumlah"
        arr(2, 0) = "Tersedia"
        arr(2, 1) = "Tidak Tersedia"
        arr(3, 0) = "Sedikit"
        arr(3, 1) = "Banyak"
        ListView1.GridLines = True
        ListView1.View = View.Details
        For baris = 0 To 1
            For kolom = 0 To 1
                ListView1.Columns.Add(arr(baris, kolom), 100) 'laptopinformatika.com
            Next
        Next
        For baris = 2 To 2
            For kolom = 0 To 1
                ComboBox1.Items.Add(arr(baris, kolom))
            Next
        Next
        For baris = 3 To 3
            For kolom = 0 To 1
                ComboBox2.Items.Add(arr(baris, kolom)) 'laptopinformatika.com
            Next
        Next
        TextBox2.Focus()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim arr(4) As String
        arr(0) = TextBox1.Text
        arr(1) = TextBox2.Text
        arr(2) = ComboBox1.Text
        arr(3) = ComboBox2.Text
        Dim list As New ListViewItem
        list = ListView1.Items.Add(arr(0))
        list.SubItems.Add(arr(1))
        list.SubItems.Add(arr(2))
        list.SubItems.Add(arr(3))
        TextBox1.Text = ""
        TextBox2.Text = ""
        ComboBox1.Text = ""
        ComboBox2.Text = ""
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim pesan As String
        pesan = MsgBox("Are you sure want to exit", vbYesNo, "laptopinformatika.com")
        If pesan = vbYes Then
            End
        End If
    End Sub
End Class


Yaa sekilas mungkin itu saja sudah cukup dan lengkap. jika kalian masih tidak mengerti atau pusing karena banyak kodingan diatas , kalian boleh langsung pakai programnya , saya akan share program yang saya buat seperti diatas. Terimakasih~

Berlangganan update artikel terbaru via email:

0 Response to "Visual Basic Lanjutan Praktikum 4 - Array Dimensi Dua"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel