Vous êtes sur la page 1sur 5

Public Class Form1 Dim kota(10, 10) As Integer Dim path(100, 100) As Integer Dim dari, ke, s, jmljalur

As Integer Dim tanda As Boolean Dim ambiljalur() As String Dim jalur(100) As String Dim topjalur, jarak As Integer Function Angka(ByVal huruf As String) As Integer Select Case huruf Case "A" Angka = 1 Case "B" Angka = 2 Case "C" Angka = 3 Case "D" Angka = 4 Case "E" Angka = 5 Case "F" Angka = 6 End Select End Function Function Abjad(ByVal angka As Integer) As Char Select Case angka Case 1 Abjad = "A" Case 2 Abjad = "B" Case 3 Abjad = "C" Case 4 Abjad = "D" Case 5 Abjad = "E" Case 6 Abjad = "F" End Select End Function Sub caripath() For i As Integer = 1 To 6 s = 0 For j As Integer = 1 To 6 If kota(i, j) = 1 Then s += 1 path(i, s) = j End If Next Next End Sub Sub bersihkan()

nodea.BackColor = Color.Blue nodeb.BackColor = Color.Blue nodec.BackColor = Color.Blue noded.BackColor = Color.Blue nodee.BackColor = Color.Blue nodef.BackColor = Color.Blue lbla.BackColor = Color.Blue lblb.BackColor = Color.Blue lblc.BackColor = Color.Blue lbld.BackColor = Color.Blue lble.BackColor = Color.Blue lblf.BackColor = Color.Blue ab.BorderWidth = 2 ac.BorderWidth = 2 ad.BorderWidth = 2 cf.BorderWidth = 2 df.BorderWidth = 2 bd.BorderWidth = 2 be.BorderWidth = 2 End Sub Sub gambarjalur() topjalur = 0 jarak = 0 ambiljalur = txthasil.Text.Split("-") jmljalur = UBound(ambiljalur) For i As Integer = 0 To jmljalur - 1 jalur(i) = ambiljalur(i) & ambiljalur(i + 1) topjalur += 1 Next For i As Integer = 0 To topjalur - 1 If jalur(i) = "AB" Or jalur(i) = "BA" Then ab.BorderWidth = 7 nodea.BackColor = Color.Lime nodeb.BackColor = Color.Lime lbla.BackColor = Color.Lime lblb.BackColor = Color.Lime jarak += 10 ElseIf jalur(i) = "AC" Or jalur(i) = "CA" Then ac.BorderWidth = 7 nodea.BackColor = Color.Lime nodec.BackColor = Color.Lime lbla.BackColor = Color.Lime lblc.BackColor = Color.Lime jarak += 25 ElseIf jalur(i) = "AD" Or jalur(i) = "DA" Then ad.BorderWidth = 7 nodea.BackColor = Color.Lime noded.BackColor = Color.Lime lbla.BackColor = Color.Lime lbld.BackColor = Color.Lime jarak += 20 ElseIf jalur(i) = "CF" Or jalur(i) = "FC" Then cf.BorderWidth = 7

Next txtjarak.Text = jarak & " Km" End Sub

nodec.BackColor = Color.Lime nodef.BackColor = Color.Lime lblc.BackColor = Color.Lime lblf.BackColor = Color.Lime jarak += 10 ElseIf jalur(i) = "DF" Or jalur(i) = "FD" Then df.BorderWidth = 7 noded.BackColor = Color.Lime nodef.BackColor = Color.Lime lbld.BackColor = Color.Lime lblf.BackColor = Color.Lime jarak += 15 ElseIf jalur(i) = "BE" Or jalur(i) = "EB" Then be.BorderWidth = 7 nodeb.BackColor = Color.Lime nodee.BackColor = Color.Lime lblb.BackColor = Color.Lime lble.BackColor = Color.Lime jarak += 15 ElseIf jalur(i) = "BD" Or jalur(i) = "DB" Then bd.BorderWidth = 7 nodeb.BackColor = Color.Lime noded.BackColor = Color.Lime lblb.BackColor = Color.Lime lbld.BackColor = Color.Lime jarak += 20 End If

Private Sub cmdtampilkan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdtampilkan.Click dari = Angka(txtdari.Text) ke = Angka(txtke.Text) If dari = ke Then MessageBox.Show("Daerah Asal dan Tujuan Tidak Boleh Sama...", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning) Exit Sub End If caripath() For i As Integer = 1 To 6 If path(dari, i) = ke Then txthasil.Text = Abjad(dari) & "-" & Abjad(path(dari, i)) bersihkan() gambarjalur() Exit Sub End If Next For j As Integer = 1 To 6 tanda = False If path(dari, j) <> 0 Then For k As Integer = 1 To 6 If path(path(dari, j), k) = ke Then tanda = True

txthasil.Text = Abjad(dari) & "-" & Abjad(path(dari, j)) & "-" & Abjad(path(path(dari, j), k)) bersihkan() gambarjalur() Exit Sub End If Next End If Next For j As Integer = 1 To 6 For l As Integer = 1 To 6 If path(path(dari, j), l) <> 0 Then For m As Integer = 1 To 6 If path(path(path(dari, j), l), m) = ke Then txthasil.Text = Abjad(dari) & "-" & Abjad(path(dari, j)) & "-" & Abjad(path(path(dari, j), l)) & "-" & Abjad(path(path(path(dari, j), l), m)) bersihkan() gambarjalur() Exit Sub End If Next Next Next End Sub Sub data() kota(1, kota(1, kota(1, kota(1, kota(1, kota(1, kota(2, kota(2, kota(2, kota(2, kota(2, kota(2, kota(3, kota(3, kota(3, kota(3, kota(3, kota(3, kota(4, kota(4, kota(4, kota(4, kota(4, kota(4, kota(5, kota(5, End If

1) 2) 3) 4) 5) 6) 1) 2) 3) 4) 5) 6) 1) 2) 3) 4) 5) 6) 1) 2) 3) 4) 5) 6) 1) 2)

= = = = = = = = = = = = = = = = = = = = = = = = = =

0 1 1 1 0 0 1 0 0 1 1 0 1 0 0 0 0 1 1 1 0 0 0 1 0 1

kota(5, kota(5, kota(5, kota(5, kota(6, kota(6, kota(6, kota(6, kota(6, kota(6, End Sub

3) 4) 5) 6) 1) 2) 3) 4) 5) 6)

= = = = = = = = = =

0 0 0 0 0 0 1 1 0 0

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

End Class