LAMPIRAN A SOURCE PROGRAM
Dim mili, dtk, mnt, jm Dim Tabu(1000) As Integer, Cek_Solusi(1000) As Integer, Solusi2(1000) As Integer, Solusi3(1000) As Integer Dim Index_Tukar As Integer, Tukar As Integer, Pnjg As Integer, Index_No_Iterasi As Integer, Tabu_Cek(1000) As Integer Private Declare Function SendMessageByNum _ Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, ByVal _ wParam As Long, ByVal lParam As Long) As Long Const LB_SETHORIZONTALEXTENT = &H194 Dim Solusi1(1000) As Integer, Index_Solusi As Integer, MaxItr1 As Integer, MaxItr2 As Integer Dim brs_Tabu As Integer, brs_Iterasi As Integer, brs_Laporan As Integer, Index_No_Tabu As Integer Dim Jarak(1000, 1000) As Integer, Index_Jarak As Integer, Index_Daftar_Jarak As Integer Dim Nama(1000) As String, Index_Nama As Integer, Respon As Integer, Titik As Integer, Index_Hapus As Integer '---------- Tombol Ambil Data untuk input ke titik awal dan tujuan' Private Sub Ambil_Data_Click() Titik_Awal.Enabled = True Titik_Tujuan.Enabled = True Text_Jarak.Enabled = True Awal.Enabled = True Akhir.Enabled = True Cek_Data.Enabled = True If Index_Daftar_Jarak < Index_Nama Then Index_Daftar_Jarak = 0 Titik_Awal.Clear Titik_Tujuan.Clear Awal.Clear Akhir.Clear For i = 1 To Titik Titik_Awal.List(Index_Daftar_Jarak) = Nama(i) Titik_Tujuan.List(Index_Daftar_Jarak) = Nama(i) Awal.List(Index_Daftar_Jarak) = Nama(i) Akhir.List(Index_Daftar_Jarak) = Nama(i) Index_Daftar_Jarak = Index_Daftar_Jarak + 1 Next
Universitas Sumatera Utara
46
Else
Respon = MsgBox(" Tidak ada data yang baru !", vbOKOnly + vbInformation, _ "Aplikasi Pencarian Jalur Terpendek") Respon = vbOKOnly End If Titik_Awal.Text = "Titik awal" Titik_Tujuan.Text = "Titik tujuan" Text_Jarak.Text = "Ketik jarak Enter" Awal.Text = "Awal" Akhir.Text = "Akhir" End Sub '---------- Tombol Cek Data untuk mengecek kesiapan data untuk diproses' Private Sub Cek_Data_Click() Tampil_Proses.Enabled = True If Index_Nama - 1 < 5 Then Respon = MsgBox(" Banyak titik minimal 5 buah !", vbOKOnly + vbInformation, _ "Aplikasi Pencarian Jalur Terpendek") Respon = vbOKOnly Else If Awal.Text = Akhir.Text Then Respon = MsgBox(" Titik awal dan akhir harus berbeda !", vbOKOnly + vbInformation, _ "Aplikasi Pencarian Jalur Terpendek") Respon = vbOKOnly Else If Awal.Text = "Awal" Or Akhir.Text = "Akhir" Then Respon = MsgBox(" Tentukan titik awal dan akhir !", vbOKOnly + vbInformation, _ "Aplikasi Pencarian Jalur Terpendek") Respon = vbOKOnly Else Respon = MsgBox(" Data siap untuk di proses !", vbOKOnly + vbInformation, _ "Aplikasi Pencarian Jalur Terpendek") Respon = vbOKOnly Proses.Enabled = True End If End If End If End Sub '---------- Deklarasi variabel awal saat aplikasi diaktifkan' Private Sub Form_Activate() Static x As Long brs_Laporan = 0 Jumlah_Titik.Text = "Banyak titik" Text_Nama.Text = "Ketik nama Enter"
Universitas Sumatera Utara
47
Titik_Awal.Text = "Titik awal" Titik_Tujuan.Text = "Titik tujuan" Text_Jarak.Text = "Ketik jarak Enter" Awal.Text = "Awal" Akhir.Text = "Akhir" For i = 1 To 100 Jumlah_Titik.AddItem i Next If x < TextWidth(Daftar_Nama.List(0) & Space(20)) Then x = TextWidth(Daftar_Nama.List(0) & Space(20)) If ScaleMode = vbTwips Then x = x / _ Screen.TwipsPerPixelX SendMessageByNum Daftar_Nama.hwnd, _ LB_SETHORIZONTALEXTENT, x, 0 End If End Sub '---------- Tombol Ganti Jarak untuk mengganti jarak yang dipilih' Private Sub Ganti_Jarak_Click() If Titik_Awal.ListIndex <> Titik_Tujuan.ListIndex And Text_Jarak <> "Ketik jarak Enter" Then Jarak(Titik_Awal.ListIndex + 1, Titik_Tujuan.ListIndex + 1) = Val(Text_Jarak) Daftar_Jarak.RemoveItem Daftar_Jarak.ListIndex Daftar_Jarak.AddItem " Jarak " & Nama(Titik_Awal.ListIndex + 1) & " -----> " _ & Nama(Titik_Tujuan.ListIndex + 1) & " = " _ & Jarak(Titik_Awal.ListIndex + 1, Titik_Tujuan.ListIndex + 1) End If If Titik_Awal.Text = "Titik awal" And Titik_Tujuan.Text = "Titik tujuan" And Text_Jarak.Text = "Ketik jarak Enter" Then Respon = MsgBox(" Tentukan data yang akan diganti !", _ vbOKOnly + vbInformation, "Aplikasi Pencarian Jalur Terpendek") Respon = vbOKOnly End If If Titik_Awal.Text = Titik_Tujuan.Text Then Respon = MsgBox(" Titik awal dan tujuan harus berbeda !", _ vbOKOnly + vbInformation, "Aplikasi Pencarian Jalur Terpendek") Respon = vbOKOnly End If If Text_Jarak.Text = "Ketik jarak Enter" Then Respon = MsgBox(" Berikan jarak yang akan diganti !", _ vbOKOnly + vbInformation, "Aplikasi Pencarian Jalur Terpendek") Respon = vbOKOnly End If Titik_Awal.Text = "Titik awal"
Universitas Sumatera Utara
48
Titik_Tujuan.Text = "Titik tujuan" Text_Jarak.Text = "Ketik jarak Enter" End Sub '---------- Tombol Hapus Daftar Jarak membersihkan layar daftar jarak sekaligus memori jarak' Private Sub Hapus_Daftar_Jarak_Click() Daftar_Jarak.Clear For i = 1 To Titik For j = 1 To Titik Jarak(i, j) = 0 Next Next Daftar_Jarak.Enabled = False End Sub '---------- Tombol Hapus Daftar Nama membersihkan layar daftar nama sekaligus memori nama' Private Sub Hapus_Daftar_Nama_Click() Respon = MsgBox(" Apakah anda yakin hapus semua nama ?", vbYesNo + vbQuestion, "Aplikasi Pencarian Jalur Terpendek") If Respon = vbYes Then Titik = 0 Index_Daftar_Jarak = 0 Daftar_Nama.Clear Daftar_Nama.Enabled = False Hapus_Nama.Enabled = False Tampil_Daftar_Nama.Enabled = False Hapus_Daftar_Nama.Enabled = False If Titik_Awal.Enabled = True Then For i = 1 To Index_Nama - 1 Titik_Awal.RemoveItem Nama(i) Titik_Tujuan.RemoveItem Nama(i) Awal.RemoveItem Nama(i) Akhir.RemoveItem Nama(i) Next Titik_Awal.Enabled = False Titik_Tujuan.Enabled = False Awal.Enabled = False Akhir.Enabled = False Ganti_Jarak.Enabled = False Text_Jarak.Enabled = False Titik_Awal.Enabled = False
Universitas Sumatera Utara
49
End If End If Index_Nama = 1 End Sub '---------- Tombol Hapus membersihkan layar semua laporan iterasi' Private Sub Hapus_Laporan_Click() Form_Proses_Iterasi.Layar_Tabu.Clear Form_Proses_Iterasi.Layar_Iterasi.Clear Laporan_Hasil.Clear End Sub '---------- Tombol Hapus untuk menghapus nama yang dipilih' Private Sub Hapus_Nama_Click() If Index_Nama > 1 Then Index_Nama = Index_Nama - 1 Titik = Titik - 1 Index_Hapus = Daftar_Nama.ListIndex + 1 Daftar_Nama.RemoveItem Daftar_Nama.ListIndex For i = Index_Hapus To Index_Nama - 1 Nama(i) = Nama(i + 1) Next Index_Daftar_Jarak = 0 End If End Sub '---------- Tombol Data untuk memberikan semua nilai awal index variabel' Private Sub Init_Data_Click() Index_Nama = 1 Index_Jarak = 1 Index_Daftar_Jarak = 0 Titik = 0 Input_Nama.Enabled = True Jumlah_Titik.Enabled = True Mdetik.Caption = "00" Detik.Caption = "00" Menit.Caption = "00" Jam.Caption = "00" End Sub '---------- Tombol Input untuk memberikan inisial nama' Private Sub Input_Nama_Click() If Val(Jumlah_Titik.Text) >= 1 Then
Universitas Sumatera Utara
50
Titik = Titik + Val(Jumlah_Titik.Text) Jumlah_Titik.Text = "Banyak titik" Text_Nama.Enabled = True Text_Nama = "" Text_Nama.SetFocus Else If Jumlah_Titik.Text = "Banyak titik" Then Respon = MsgBox(" Berikan banyak titik !", vbOKOnly + vbInformation, "Aplikasi Pencarian Jalur Terpendek") Respon = vbOKOnly End If End If End Sub '---------- Tombol Keluar untuk menutup aplikasi' Private Sub Keluar_Click() Respon = MsgBox("Apakah anda yakin keluar aplikasi ?", vbYesNo + vbQuestion, _ "Aplikasi Pencarian Jalur Terpendek") If Respon = vbYes Then End End If End Sub '---------- Tombol Proses... untuk menjalankan proses iterasi' Private Sub Proses_Click() Timer1.Enabled = True Call Timer1_Timer Reset.Enabled = True Laporan_Hasil.Enabled = True Hapus_Laporan.Enabled = True Simpan.Enabled = True Form_Proses_Iterasi.Layar_Tabu.Enabled = True Form_Proses_Iterasi.Layar_Iterasi.Enabled = True DoEvents brs_Tabu = 0 brs_Iterasi = 0 brs_Laporan = 0 For i = 0 To 1000 Solusi1(i) = 0 Solusi2(i) = 0 Solusi3(i) = 0 Tabu(i) = 0 Tabu_Cek(i) = 0 Cek_Solusi(i) = 0 DoEvents Next '*********** Tetapkan
maksimum iterasi **********'
Universitas Sumatera Utara
51
MaxItr1 = ((Titik - 2) * (Titik - 3)) / 2 MaxItr2 = MaxItr1 - 1 '*************************************************' '*********** Bagian inisial solusi awal ************' Index_Solusi = 1 Solusi1(Index_Solusi) = Awal.ListIndex + 1 For i = 1 To Titik DoEvents If i <> Awal.ListIndex + 1 And i <> Akhir.ListIndex + 1 Then Solusi1(Index_Solusi + 1) = i Index_Solusi = Index_Solusi + 1 End If Next Solusi1(Index_Solusi + 1) = Akhir.ListIndex + 1 '***************************************************' '*********** Bagian cek jarak solusi awal **********' n2 = 2 n1 = 1 Index_Solusi = 2 For i = 1 To 1000 DoEvents If Jarak(Solusi1(n1), Solusi1(Index_Solusi)) <> 0 Then If Solusi1(Index_Solusi) = Akhir.ListIndex + 1 Then DoEvents Exit For End If n1 = Index_Solusi Index_Solusi = Index_Solusi + 1 n2 = Index_Solusi Else If Solusi1(Index_Solusi) = Akhir.ListIndex + 1 Then DoEvents Exit For Else Tukar = Solusi1(n2 + 1) Solusi1(n2 + 1) = Solusi1(Index_Solusi) Solusi1(Index_Solusi) = Tukar n2 = n2 + 1 End If End If Next '*************************************************' '*********** Bagian inisial solusi tabu awal **********' For i = 1 To Index_Solusi DoEvents Cek_Solusi(i) = Solusi1(i) Next
Universitas Sumatera Utara
52
For i = 1 To Index_Solusi DoEvents Tabu(i) = Solusi1(i) Next Pnjg = 0 For i = 1 To Index_Solusi - 1 DoEvents Pnjg = Pnjg + Jarak(Tabu(i), Tabu(i + 1)) Next '*************************************************' '*********** Bagian output solusi awal Tabu **********' Form_Proses_Iterasi.Layar_Tabu.List(brs_Tabu) = "1. For i = 1 To Index_Solusi Form_Proses_Iterasi.Layar_Tabu.List(brs_Tabu) = Form_Proses_Iterasi.Layar_Tabu.List(brs_Tabu) _ & Tabu(i) & " " Next Form_Proses_Iterasi.Layar_Tabu.List(brs_Tabu) = Form_Proses_Iterasi.Layar_Tabu.List(brs_Tabu) _ & " ---->" & " Total jarak = " & Pnjg
"
'*************************************************' '*********** Bagian inisial solusi awal ************' Index_Solusi = 1 Solusi1(Index_Solusi) = Awal.ListIndex + 1 For i = 1 To Titik DoEvents If i <> Awal.ListIndex + 1 And i <> Akhir.ListIndex + 1 Then Solusi1(Index_Solusi + 1) = i Index_Solusi = Index_Solusi + 1 End If Next Solusi1(Index_Solusi + 1) = Akhir.ListIndex + 1 '***************************************************' '*********** Bagian proses iterasi dan tabu list **********' Index_No_Tabu = 2 brs_Tabu = 1 brs_Iterasi = 0 n1 = 2 n2 = 3 For i = 1 To MaxItr2 DoEvents Index_No_Iterasi = 1 n3 = 2 n6 = n3 + 1 Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) = "Tetangga (Jalur lain yang mungkin):" brs_Iterasi = brs_Iterasi + 1
Universitas Sumatera Utara
53
Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) = "" brs_Iterasi = brs_Iterasi + 1 For m = 1 To Titik DoEvents Solusi3(m) = Solusi1(m) Next For j = 1 To MaxItr1 + 1 DoEvents n4 = 1 n5 = 1 For k = 2 To Titik DoEvents If Jarak(Solusi3(n4), Solusi3(k)) <> 0 Then Solusi2(n5) = Solusi3(n4) n4 = k n5 = n5 + 1 End If Next Solusi2(n5) = Solusi3(n4) p = 0 For k = 1 To n5 - 1 DoEvents p = p + Jarak(Solusi2(k), Solusi2(k + 1)) Next If Solusi2(n5) = Akhir.ListIndex + 1 And p <= Pnjg Then Pnjg = p For k = 1 To n5 DoEvents Tabu(k) = Solusi2(k) Next Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) = Index_No_Iterasi & ". " For k = 1 To n5 DoEvents Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) = _ Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) & Tabu(k) & " " Next Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) = _ Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) & " ---->" & " Total jarak = " & Pnjg brs_Iterasi = brs_Iterasi + 1 Index_No_Iterasi = Index_No_Iterasi + 1 n7 = n5 Else If Solusi2(n5) = Akhir.ListIndex + 1 Then Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) = Index_No_Iterasi & ". " For k = 1 To n5 DoEvents
Universitas Sumatera Utara
54
Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) = _ Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) & Solusi2(k) & " " Next Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) = _ Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) & " ---->" & " Total jarak = " & p brs_Iterasi = brs_Iterasi + 1 Index_No_Iterasi = Index_No_Iterasi + 1 End If End If DoEvents If n6 = Titik Then n3 = n3 + 1 n6 = n3 + 1 Else n6 = n6 + 1 End If For m = 1 To Titik DoEvents Solusi3(m) = Solusi1(m) Next Tukar = Solusi3(n6) Solusi3(n6) = Solusi3(n3) Solusi3(n3) = Tukar DoEvents Next Form_Proses_Iterasi.Layar_Iterasi.List(brs_Iterasi) = "" brs_Iterasi = brs_Iterasi + 1 Tukar = Solusi1(n2) Solusi1(n2) = Solusi1(n1) Solusi1(n1) = Tukar n2 = n2 + 1 If n2 = Titik Then n2 = 3 End If DoEvents n8 = 0 For k = 1 To n7 DoEvents If Tabu(k) = Tabu_Cek(k) Then n8 = n8 + 1 End If If n8 = n7 Then DoEvents GoTo pindah1 End If Next For k = 1 To n7
Universitas Sumatera Utara
55
DoEvents Tabu_Cek(k) = Tabu(k) Next Form_Proses_Iterasi.Layar_Tabu.List(brs_Tabu) = Index_No_Tabu & ". " For k = 1 To n7 DoEvents Form_Proses_Iterasi.Layar_Tabu.List(brs_Tabu) Form_Proses_Iterasi.Layar_Tabu.List(brs_Tabu) Tabu(k) & " " Next Form_Proses_Iterasi.Layar_Tabu.List(brs_Tabu) Form_Proses_Iterasi.Layar_Tabu.List(brs_Tabu) -->" & " Total jarak = " & Pnjg brs_Tabu = brs_Tabu + 1 Index_No_Tabu = Index_No_Tabu + 1 DoEvents pindah1: Next DoEvents
= _ & = _ & "
--
'*************************************************' '---------- bagian cetak layar pada form aplikasi' DoEvents Laporan_Hasil.List(brs_Laporan) = "" brs_Laporan = brs_Laporan + 1 Laporan_Hasil.List(brs_Laporan) = "Maka Diperoleh Jalur Terpendek : " brs_Laporan = brs_Laporan + 1 Laporan_Hasil.List(brs_Laporan) = "" For k = 1 To n7 DoEvents Laporan_Hasil.List(brs_Laporan) = Laporan_Hasil.List(brs_Laporan) & Nama(Tabu(k)) & " " Next Laporan_Hasil.List(brs_Laporan) = Laporan_Hasil.List(brs_Laporan) & " ---->" & " Total jarak = " & Pnjg DoEvents Timer1.Enabled = False Proses.Enabled = False '---------------------------------------------------------------If x < TextWidth(Laporan_Hasil.List(0) & Space(50)) Then x = TextWidth(Laporan_Hasil.List(0) & Space(50)) If ScaleMode = vbTwips Then x = x / _ Screen.TwipsPerPixelX SendMessageByNum Laporan_Hasil.hwnd, _ LB_SETHORIZONTALEXTENT, x, 0 End If
Universitas Sumatera Utara
56
If x < TextWidth(Form_Proses_Iterasi.Layar_Tabu.List(0) & Space(50)) Then x = TextWidth(Form_Proses_Iterasi.Layar_Tabu.List(0) & Space(50)) If ScaleMode = vbTwips Then x = x / _ Screen.TwipsPerPixelX SendMessageByNum Form_Proses_Iterasi.Layar_Tabu.hwnd, _ LB_SETHORIZONTALEXTENT, x, 0 End If If x < TextWidth(Form_Proses_Iterasi.Layar_Iterasi.List(0) & Space(50)) Then x = TextWidth(Form_Proses_Iterasi.Layar_Iterasi.List(0) & Space(50)) If ScaleMode = vbTwips Then x = x / _ Screen.TwipsPerPixelX SendMessageByNum Form_Proses_Iterasi.Layar_Iterasi.hwnd, _ LB_SETHORIZONTALEXTENT, x, 0 End If End Sub '---------- Tombol Reset mengembalikan nilai waktu pada posisi nol' Private Sub Reset_Click() Mdetik.Caption = "00" Detik.Caption = "00" Menit.Caption = "00" Jam.Caption = "00" mili = 0 dtk = 0 mnt = 0 jm = 0 End Sub
'---------- Tombol Simpan dalam file text notepad'
untuk menyimpan hasil laporan iterasi
Private Sub Simpan_Click() Form_Proses_Iterasi.CommonDialog1.Filter = "Text file | *.txt" Form_Proses_Iterasi.CommonDialog1.ShowSave If Form_Proses_Iterasi.CommonDialog1.FileName <> "" Then Open Form_Proses_Iterasi.CommonDialog1.FileName For Output As #2
Print TERPENDEK " Print ------" Print Print Print Print Print For i
#2, "LAPORAN PROSES ITERASI APLIKASI PENCARIAN JALUR #2, "-------------------------------------------------#2, #2, #2, #2, #2, = 0
"" "" "BAGIAN I LAPORAN HASIL JARAK" "----------------------------" "" To brs_Laporan
Universitas Sumatera Utara
57
Print #2, Laporan_Hasil.List(i) Next Print #2, "" Print #2, "" Print #2, "BAGIAN I LAPORAN TABU LIST" Print #2, "--------------------------" Print #2, "" For i = 0 To brs_Tabu Print #2, Form_Proses_Iterasi.Layar_Tabu.List(i) Next Print #2, "" Print #2, "" Print #2, "BAGIAN II LAPORAN PROSES ITERASI" Print #2, "--------------------------------" Print #2, "" For i = 0 To brs_Iterasi Print #2, Form_Proses_Iterasi.Layar_Iterasi.List(i) Next Print #2, "" Print #2, "" Print #2, ".........................LAPORAN PROSES SELESAI......................!!!!" Print #2, "" Print #2, "" Close #2 End If End Sub '---------- Tombol Tampil/Urut untuk menampilkan nama dan mengurutkannya sesuai indeks nomor' Private Sub Tampil_Daftar_Nama_Click() Daftar_Nama.Enabled = True Hapus_Daftar_Nama.Enabled = True For i = 1 To Index_Nama - 1 Daftar_Nama.List(i - 1) = i & ". Next
" & Nama(i)
If x < TextWidth(Daftar_Nama.List(0) & Space(50)) Then x = TextWidth(Daftar_Nama.List(0) & Space(50)) If ScaleMode = vbTwips Then x = x / _ Screen.TwipsPerPixelX SendMessageByNum Daftar_Nama.hwnd, _ LB_SETHORIZONTALEXTENT, x, 0 End If End Sub '---------- Tombol Tampilkan Proses untuk membuka layar proses iterasi dan tabulist' Private Sub Tampil_Proses_Click() Form_Proses_Iterasi.Show End Sub
Universitas Sumatera Utara
58
'---------- bagian pengosongan karakter text input jarak saat di klik' Private Sub Text_Jarak_Click() Text_Jarak.Text = "" End Sub '---------- bagian input jarak saat text ditekan enter' Private Sub Text_Jarak_KeyDown(KeyCode As Integer, Shift As Integer) If Text_Jarak <> "" And KeyCode = 13 And Titik_Awal.ListIndex <> Titik_Tujuan.ListIndex Then Jarak(Titik_Awal.ListIndex + 1, Titik_Tujuan.ListIndex + 1) = Val(Text_Jarak) Daftar_Jarak.Enabled = True Hapus_Daftar_Jarak.Enabled = True Ganti_Jarak.Enabled = True Daftar_Jarak.AddItem " Jarak " & Nama(Titik_Awal.ListIndex + 1) & " -----> " _ & Nama(Titik_Tujuan.ListIndex + 1) & " = " _ & Jarak(Titik_Awal.ListIndex + 1, Titik_Tujuan.ListIndex + 1) Titik_Awal.Text = "Titik awal" Titik_Tujuan.Text = "Titik tujuan" Text_Jarak.Text = "Ketik jarak Enter" End If If Text_Jarak <> "" And KeyCode = 13 And Titik_Awal.Text = Titik_Tujuan.Text Then Respon = MsgBox(" Titik awal dan tujuan harus berbeda !", _ vbOKOnly + vbInformation, "Aplikasi Pencarian Jalur Terpendek") Respon = vbOKOnly Titik_Awal.Text = "Titik awal" Titik_Tujuan.Text = "Titik tujuan" Text_Jarak.Text = "Ketik jarak Enter" End If If x < TextWidth(Daftar_Jarak.List(0) & Space(50)) Then x = TextWidth(Daftar_Jarak.List(0) & Space(50)) If ScaleMode = vbTwips Then x = x / _ Screen.TwipsPerPixelX SendMessageByNum Daftar_Jarak.hwnd, _ LB_SETHORIZONTALEXTENT, x, 0 End If End Sub '---------- bagian input nama saat text ditekan enter' Private Sub Text_Nama_KeyDown(KeyCode As Integer, Shift As Integer) If Text_Nama <> "" And KeyCode = 13 And Index_Nama <= Titik Then
Universitas Sumatera Utara
59
Nama(Index_Nama) = Text_Nama Tampil_Daftar_Nama.Enabled = True Hapus_Nama.Enabled = True Ambil_Data.Enabled = True Text_Nama.Text = "" Index_Nama = Index_Nama + 1 End If If Index_Nama > Titik Then Text_Nama.Text = "Ketik nama Enter" Text_Nama.Enabled = False End If End Sub '---------- bagian timer pencatat waktu iterasi berjalan' Private Sub Timer1_Timer() mili = Val(mili) + 1 md = Len(mili) If mili > 59 Then mili = "00" dtk = Val(dtk) + 1 d = Len(dtk) If dtk > 59 Then dtk = "00" mnt = Val(mnt) + 1 m = Len(mnt) If mnt > 59 Then mnt = "00" jm = Val(jm) + 1 j = Len(jm) If jm > 23 Then jm = "00" End If If j = 1 Then Jam.Caption = "0" & jm Else Jam.Caption = jm End If End If If m = 1 Then Menit.Caption = "0" & mnt Else Menit.Caption = mnt
Universitas Sumatera Utara
60
End If End If If d = 1 Then Detik.Caption = "0" & dtk Else Detik.Caption = dtk End If End If If md = 1 Then Mdetik.Caption = "0" & mili Else Mdetik.Caption = mili End If End SubSDS
Universitas Sumatera Utara