MEMBUAT MATRIKS
ASSALAMU'ALAIKUM WARAHMATULLAHI WABAROKATUH :)
SELAMAT DATANG DI BLOG SAYA, SAYA AKAN MEMPOSTING
MENGENAI PROGRAM VISUAL BASIC 10 YANG
SAYA BUAT
PROJECT LATIHAN 17
BERIKUT CODING CARA MENCARI MATRIKS:
Public Class Formlat_17
Dim matrikA(20, 20), matrikB(20, 20), barisA, kolomA,
barisB, kolomB As Integer
Dim kalimatrik, hasilmatrikA, hasilmatrikB,
hasilmatrik As String
'proses input matrika
Sub input_matrikA()
Dim b, k As Integer
barisA =
Val(Me.TxtbykBaris.Text)
kolomA =
Val(Me.TxtbnykKolom.Text)
For b = 0 To barisA -
1
For k = 0 To kolomA -
1
matrikA(b, k) = InputBox("Masukan Nilai
Matriks A untuk posisi " & b + 1 & "x"
& k + 1 & " : ")
Next
Next
End Sub
Sub cetak_matrikA()
Dim b, k As Integer
barisA =
Val(Me.TxtbykBaris.Text)
kolomA =
Val(Me.TxtbnykKolom.Text)
For b = 0 To barisA -
1
For k = 0 To kolomA - 1
hasilmatrikA = hasilmatrikA & matrikA(b, k) & " "
Me.LBMatrik_A.Text = matrikA(b, k).ToString & " "
Next
hasilmatrikA = hasilmatrikA & Chr(13)
Next
Me.LBMatrik_A.Text = hasilmatrikA.ToString
End Sub
Sub input_matrikB()
Dim b, k As Integer
barisB =
Val(Me.TxtbykBarisB.Text)
kolomB =
Val(Me.TxtbykkolomB.Text)
For b = 0 To barisB -
1
For k = 0 To kolomB -
1
matrikB(b, k) = InputBox("Masukan Nilai
Matriks B untuk posisi " & b + 1 & "x"
& k + 1 & " : ")
Next
Next
End Sub
Sub cetak_matrikB()
Dim b, k As Integer
barisB =
Val(Me.TxtbykBarisB.Text)
kolomB =
Val(Me.TxtbykkolomB.Text)
For b = 0 To barisB -
1
For k = 0 To kolomB -
1
hasilmatrikB = hasilmatrikB & matrikB(b, k) & " "
Me.LbhasilmatrikB.Text = hasilmatrikB.ToString & " "
Next
hasilmatrikB = hasilmatrikB & Chr(13)
Next
Me.LbhasilmatrikB.Text = hasilmatrikB.ToString
End Sub
Sub kali_matrikAB()
Dim bA, kA, bB, kB As
Integer
barisA =
Val(Me.TxtbykBaris.Text)
kolomA =
Val(Me.TxtbnykKolom.Text)
barisB =
Val(Me.TxtbykBarisB.Text)
kolomB =
Val(Me.TxtbykkolomB.Text)
'matrik A
For b = 0 To barisA -
1
For k = 0 To kolomA -
1
'matrik B
For bB = 0 To barisB
- 1
For kB = 0 To
kolomB - 1
kalimatrik = kalimatrik & (matrikA(bA, kA) * matrikB(bB, kB))
Next
hasilmatrik = hasilmatrik & kalimatrik
Next
hasilmatrik = hasilmatrik & " "
Next
hasilmatrik = hasilmatrik & Chr(13)
Next
Me.LBHMatrik.Text = hasilmatrik.ToString
End Sub
Private Sub
Formlat_17_FormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
utama.Enabled = True
utama.Show()
Me.Hide()
End Sub
Private Sub
Formlat_17_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
utama.Enabled = True
utama.Show()
Me.Hide()
End Sub
Private Sub
BProses_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
BProses.Click
Call input_matrikA()
Call input_matrikB()
Call cetak_matrikA()
Call cetak_matrikB()
Call kali_matrikAB()
End Sub
End Class
Tidak ada komentar:
Posting Komentar