listing program
TRANSCRIPT
LAMPIRAN A-1
LISTING PROGRAM
1. Login
Option ExplicitDim rsUser As Recordset
Private Sub cboUser_Click() txtPass.Locked = False txtPass.SetFocusEnd Sub
Private Sub cmdCancel_Click()EndEnd Sub
Private Sub cmdOK_Click()On Error Resume NextSet rsCari = New ADODB.Recordset rsCari.Open "Select * from tUser where UserId='" & cboUser.Text & "' and Passwd='" & txtPass.Text & "'", CN, adOpenDynamic, adLockOptimistic If rsCari.EOF = True Then MsgBox "Password salah" txtPass = "" cboUser = "" cboUser.SetFocus Else Me.Hide frmUtama.Show End IfEnd Sub
Private Sub Form_Activate()txtPass = ""cboUser = ""cboUser.SetFocusEnd SubPrivate Sub Form_Load()KoneksiSet rsUser = New ADODB.RecordsetrsUser.Open "Select * from tUser order by UserId asc", CN, adOpenDynamic, adLockOptimisticDo Until rsUser.EOF = TruecboUser.AddItem rsUser.Fields("UserId")rsUser.MoveNextLoopEnd SubPrivate Sub txtPass_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then cmdOk.Enabled = True cmdOk.SetFocusEnd IfEnd SubPrivate Sub cboUser_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then txtPass.Locked = False txtPass.SetFocusEnd IfEnd Sub
LAMPIRAN A-2
2. Menu Utama
Private Sub cmdAbout_Click()frmAbout.ShowEnd Sub
Private Sub cmdQuit_Click()EndEnd Sub
Private Sub cmdReq_Click()MainForm.ShowEnd Sub
Private Sub cmdUtil_Click()frmMenuADM.ShowEnd Sub
Private Sub Form_Activate()Timer1.Enabled = TrueEnd Sub
3.Request
Dim rsLagu As RecordsetDim KdLagu As StringDim IDRequest As Integer
Private Sub cmdQuit_Click()If InTray = True ThenCall TrayModule.DeleteIcon(MainForm)End IfUnload MeUnload AddFormEnd Sub
Private Sub cmdStart_Click()cmdStart.Enabled = FalseCall StartEnd SubSub Start()Set rsCari = New ADODB.Recordset rsCari.Open "Select * from tDatarequest where stPutar = '1' order by idrequest asc", CN, 1, 2 If Not rsCari.EOF Then KdLagu = rsCari!KdLagu lblKdLagu = KdLagu IDRequest = rsCari!IDRequest Set rsLagu = New ADODB.Recordset rsLagu.Open "Select * from tLagu where KdLagu='" & KdLagu & "'", CN, 1, 2 If Not rsLagu.EOF Then lblNmFile.Caption = rsLagu!NmFile lblNmLagu.Caption = rsLagu!Nmlagu If Music.ListCount > 0 Then Module1.MusicClick End If Else
LAMPIRAN A-3
lblNmFile.Caption = "" End If Set rsLagu = Nothing Else KdLagu = "" End If Set rsCari = NothingSet rsCari = New ADODB.Recordset rsCari.Open "Update tDatarequest SET stPutar= '*' where idrequest=" & IDRequest & "", CN, 1, 2Set rsCari = NothingEnd Sub
Private Sub Command1_Click()AddForm.ShowEnd Sub
Private Sub Command2_Click()On Error GoTo skipDim Selected As IntegerMusicName = Music.TextSelected = Music.ListIndexMusic.RemoveItem (Selected)PathList.RemoveItem (Selected)Module1.SaveFilePlay2action.Enabled = TrueTimer1.Enabled = Falseleftlabel.Caption = "0"Playaction.Enabled = Truepauseaction.Enabled = Falsepausebutton.Enabled = Falsestopbutton.Enabled = Falsestopaction.Enabled = FalseExit SubEnd Sub
Private Sub deleteaction_Click()On Error GoTo skipMusicName = Music.TextMusic.RemoveItem (Music.ListIndex)WindowsMediaPlayer1.Controls.Stopplaybutton.Enabled = TruePlayaction.Enabled = TruePlay2action.Enabled = TrueExit SubEnd Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)If InTray = True Then If X = TrayModule.WM_RBUTTONDOWN Then PopupMenu TrayMenu ElseIf X = TrayModule.WM_LBUTTONDBLCLK Then If InTray = True Then MainForm.Show Call TrayModule.DeleteIcon(MainForm) End If End IfEnd IfEnd Sub
LAMPIRAN A-4
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)Label1.ToolTipText = Music.ListCount & " uploaded songs"End Sub
Private Sub grid_Click() Dim i As Integer i = grid.Row KdLagu = grid.TextMatrix(i, 4) lblKdLagu = KdLagu Set rsCari = New ADODB.Recordset rsCari.Open "Select * from tLagu where KdLagu='" & KdLagu & "'", CN, 1, 2 If Not rsCari.EOF Then lblNmFile.Caption = rsCari!NmFile lblNmLagu.Caption = rsCari!Nmlagu If Music.ListCount > 0 Then Module1.MusicClick End If Else lblNmFile.Caption = "" End IfEnd Sub
Private Sub Music_Click()If Music.ListCount > 0 Then Module1.MusicClickEnd IfEnd Sub
Private Sub Music_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 1 ThenModule1.MusicClickElseIf Button = 2 ThenPopupMenu musicmenuEnd IfEnd Sub
Private Sub Music_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)Music.ToolTipText = MusicNameEnd Sub
Private Sub NextAction_Click()Call TrayNext_ClickEnd Sub
Private Sub OrderAction_Click()Dim MusicName As StringDim MusicPath As StringDim i, j, k As IntegerDim Index1, Index2 As IntegerDim Letter1, Letter2 As StringDim OldCaption As StringOldCaption = Me.CaptionMe.Caption = "Ordering..."
LAMPIRAN A-5
If Music.ListCount >= 2 Theni = Music.ListCount - 2Do While i > -1j = 1
Compare:Letter1 = UCase(Mid(Music.List(i), j, 1))Letter2 = UCase(Mid(Music.List(i + 1), j, 1))
If Letter2 < Letter1 ThenSwitch: Index1 = i Index2 = i + 1 MusicName = Music.List(Index1) MusicPath = PathList.List(Index1) Music.RemoveItem Index1 PathList.RemoveItem Index1 Music.AddItem MusicName, Index2 PathList.AddItem MusicPath, Index2 If i <> Music.ListCount - 2 Then i = i + 2 End If ElseIf Letter2 = Letter1 Then If j >= Len(Music.List(i + 1)) And j < Len(Music.List(i)) Then GoTo Switch ElseIf j >= Len(Music.List(i)) Then GoTo Cont Else j = j + 1 GoTo Compare End If End IfCont:i = i - 1LoopEnd IfMe.Caption = OldCaptionEnd Sub
Private Sub Play2action_Click()Module1.PlayEnd Sub
Private Sub playbutton_Click()playbutton.Enabled = TrueModule1.PlayEnd Sub
Private Sub pausebutton_Click()Module1.PauseEnd SubPrivate Sub playmenu_Click()If Music.ListCount > 0 ThenNextAction.Enabled = TrueBackAction.Enabled = TrueEnd IfEnd Sub
LAMPIRAN A-6
Private Sub SendToTray_Click()If InTray = False ThenMe.Hide Call TrayModule.AddIcon(MainForm, currentlyplaying) End IfEnd Sub
Private Sub ShowAction_Click()If InTray = True ThenMainForm.ShowCall TrayModule.DeleteIcon(MainForm)End IfEnd Sub
Private Sub ShuffleAction_Click()Dim Songs As IntegerDim i As IntegerDim NewPos As IntegerDim Name1 As StringDim Name2 As StringDim Path1, Path2 As StringDim Taken() As IntegerRandomizeSongs = Music.ListCountReDim Taken(Songs) As Integeri = 0
Do While i < SongsTaken(i) = 0i = i + 1Loop
i = 0Do While i < SongsIf Taken(i) = 0 ThenNewPos = (Rnd * (Songs - 2)) + 1Taken(i) = 1Taken(NewPos) = 1Name1 = Music.List(i)Path1 = PathList.List(i)Name2 = Music.List(NewPos)Path2 = PathList.List(NewPos)Music.List(i) = Name2PathList.List(i) = Path2Music.List(NewPos) = Name1PathList.List(NewPos) = Path1End Ifi = i + 1LoopMusic.RefreshEnd Sub
Private Sub Slider1_KeyDown(KeyCode As Integer, Shift As Integer)If KeyCode = 39 Or KeyCode = 37 ThenOn Error GoTo skipmoving = TrueEnd IfExit Subskip:End Sub
LAMPIRAN A-7
Private Sub Slider1_KeyUp(KeyCode As Integer, Shift As Integer)If KeyCode = 39 Or KeyCode = 37 ThenOn Error GoTo skipWindowsMediaPlayer1.Controls.currentPosition = Slider1.Valueleftlabel.Caption = Slider1.Valuemoving = FalseEnd IfExit Subskip:End Sub
Private Sub Slider1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)On Error GoTo skipIf Button = 1 Thenmoving = TruePButton = 1ElsePButton = 2End IfExit Subskip:End Sub
Private Sub Slider1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)On Error GoTo skipIf PButton = 1 ThenWindowsMediaPlayer1.Controls.currentPosition = Slider1.Valueleftlabel.Caption = Slider1.Valuemoving = FalseEnd IfExit Subskip:End Sub
Private Sub stopbutton_Click()Module1.StopSongplaybutton.Enabled = TrueEnd Sub
Private Sub Cover_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 2 ThenPopupMenu playmenuEnd IfEnd SubSub Segar()Set rsCari = New ADODB.Recordset rsCari.Open "Select * from tDataRequest order by IdRequest asc", CN, 1, 2Adodc1.Refreshgrid.Refreshgrid.ColWidth(0) = 0grid.ColWidth(1) = 1000grid.ColWidth(2) = 1000grid.ColWidth(3) = 1200grid.ColWidth(4) = 1200grid.TextMatrix(0, 0) = ""grid.TextMatrix(0, 1) = "Id Req"
LAMPIRAN A-8
grid.TextMatrix(0, 2) = "Id SMS"grid.TextMatrix(0, 3) = "Tgl Req"grid.TextMatrix(0, 4) = "Kode Lagu"Set rsCari = NothingEnd SubPrivate Sub Form_Activate()Call SegarEnd Sub
Private Sub Form_Load()KoneksiDim FR As IntegerDim FullName As StringDim i As IntegerDim DirName As StringFR = FreeFile
Music.ClearPathList.ClearVolumeControl.Value = WindowsMediaPlayer1.Settings.Volumeleftlabel.Caption = "-1"moving = Falseautoloading = True
If DirName <> "" Then Do While Not EOF(FR) Input #FR, FullName PathList.AddItem FullName MusicName = FullName i = InStr(1, MusicName, "\", vbTextCompare) Do While i > 0 MusicName = Mid(MusicName, i + 1) i = InStr(1, MusicName, "\", vbTextCompare) Loop MainForm.Music.AddItem MusicName Loop Close #FRexitloop: autoloading = False currentlyplaying = "" Call OrderAction_ClickEnd IfEnd Sub
Private Sub Form_Unload(Cancel As Integer)If InTray = True ThenCall TrayModule.DeleteIcon(MainForm)End IfUnload MeUnload AddFormEnd Sub
Private Sub minaction_Click()MainForm.WindowState = 1Unload AddFormEnd Sub
Private Sub pauseaction_Click()Module1.PauseEnd Sub
LAMPIRAN A-9
Private Sub playaction_Click()Module1.PlayEnd Sub
Private Sub quitaction_Click()Unload MeUnload AddFormEnd Sub
Private Sub Stopaction_Click()Module1.StopSongEnd Sub
Private Sub Timer1_Timer()leftlabel.Caption = leftlabel.Caption + 1If leftlabel.Caption >= WindowsMediaPlayer1.currentMedia.duration And WindowsMediaPlayer1.currentMedia.duration > 0 ThenOn Error GoTo restartMusic.ListIndex = Music.ListIndex + 1leftlabel.Caption = "0"End IfTimer1.Enabled = FalseTimer1.Enabled = TrueIf moving = False ThenTimer2.Enabled = TrueSlider1.Value = WindowsMediaPlayer1.Controls.currentPositionEnd IfModule1.ConvertMinuets (Slider1.Value)Dim temp As Stringtemp = CTimeModule1.ConvertMinuets (WindowsMediaPlayer1.currentMedia.duration)Slider1.ToolTipText = temp & "/" & CTimeExit Subrestart: Music.ListIndex = 0leftlabel.Caption = "0"End Sub
Private Sub Timer2_Timer()On Error GoTo atemptcurrentduration = WindowsMediaPlayer1.currentMedia.durationSlider1.Max = currentdurationTimer2.Enabled = FalseExit Subatempt: currentduration = WindowsMediaPlayer1.currentMedia.durationIf currentduration > 0 Then Slider1.Max = currentdurationTimer2.Enabled = FalseEnd Sub
Private Sub TrayBack_Click()On Error GoTo 1If Music.ListIndex > 0 ThenMusic.ListIndex = Music.ListIndex - 1ElseGoTo 1End IfExit Sub1: Music.ListIndex = Music.ListCount - 1End Sub
LAMPIRAN A-10
Private Sub TrayExit_Click()Unload MeUnload AddFormEnd Sub
Private Sub TrayMenu_Click()If playbutton.Enabled = True ThenTrayPlay.Enabled = TrueElseTrayPlay.Enabled = FalseEnd If
If pausebutton.Enabled = True ThenTrayPause.Enabled = TrueElseTrayPause.Enabled = FalseEnd If
If stopbutton.Enabled = True ThenTrayStop.Enabled = TrueElseTrayStop.Enabled = FalseEnd If
If Music.ListCount > 0 ThenTrayNext.Enabled = TrueTrayBack.Enabled = TrueElseTrayNext.Enabled = FalseTrayBack.Enabled = FalseEnd IfEnd Sub
Private Sub TrayNext_Click()On Error GoTo 1Music.ListIndex = Music.ListIndex + 1Exit Sub1: Music.ListIndex = 0End Sub
Private Sub TrayPause_Click()Module1.PauseEnd Sub
Private Sub TrayPlay_Click()Module1.PlayEnd Sub
Private Sub TrayStop_Click()Module1.StopSongEnd Sub
Private Sub Unload2action_Click()On Error GoTo skipDim iFor i = 0 To Music.ListCount - 1 If Music.Selected(i) Then Music.RemoveItem (i) WindowsMediaPlayer1.Controls.Stop Timer1.Enabled = False
LAMPIRAN A-11
playbutton.Enabled = TruePlayaction.Enabled = TruePlay2action.Enabled = Falseleftlabel.Caption = "0"stopbutton.Enabled = Falsestopaction.Enabled = Falsepausebutton.Enabled = Falsepauseaction.Enabled = False End IfNext iExit Subskip:End Sub
Private Sub unloadaction_Click()Music.ClearTimer1.Enabled = FalseWindowsMediaPlayer1.Controls.Stopleftlabel.Caption = "0"playbutton.Enabled = FalsePlayaction.Enabled = FalsePlay2action.Enabled = Falsestopbutton.Enabled = Falsestopaction.Enabled = Falsepausebutton.Enabled = Falsepauseaction.Enabled = FalseMe.Caption = "J34 Media Player"End Sub
Private Sub VolumeControl_Change()WindowsMediaPlayer1.Settings.Volume = VolumeControl.ValueEnd Sub
Private Sub VolumeControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)VolumeControl.ToolTipText = VolumeControl.ValueEnd Sub
Private Sub WindowsMediaPlayer1_MouseDown(ByVal nButton As Integer, ByVal nShiftState As Integer, ByVal fX As Long, ByVal fY As Long)If nButton = 2 ThenPopupMenu playmenuEnd IfEnd Sub
4. Menu Utility
Private Sub cmdLagu_Click()frmLagu.ShowEnd Sub
Private Sub cmdUser_Click()frmUser.ShowEnd Sub
Private Sub cmdKeluar_Click()Me.HideUnload MefrmUtama.ShowEnd Sub
LAMPIRAN A-12
Private Sub Form_Unload(Cancel As Integer)Me.HideUnload MefrmUtama.ShowEnd Sub
5. Data Lagu
Option ExplicitDim rsKata As RecordsetSub Segar()Set rsCari = New ADODB.Recordset rsCari.Open "Select * from tLagu order by KdLagu asc", CN, 1, 2Adodc1.Refreshgrid.Refreshgrid.ColWidth(0) = 0grid.ColWidth(1) = 1000grid.ColWidth(2) = 4000grid.ColWidth(3) = 7000grid.TextMatrix(0, 0) = ""grid.TextMatrix(0, 1) = "Kode"grid.TextMatrix(0, 2) = "Nama Lagu"grid.TextMatrix(0, 3) = "Nama File"End Sub
Private Sub cmdBatal_Click()matibersihtambah = FalseCari = Falseubah = FalsecmdTambah.Enabled = TruecmdCari.Enabled = TruecmdRubah.Visible = TruecmdRubah.Enabled = FalsecmdUpdate.Visible = FalsecmdHapus.Enabled = FalsecmdBatal.Enabled = TruecmdTambah.Visible = TruecmdTambah.Enabled = TruecmdSave.Visible = FalsecmdTambah.SetFocusEnd Sub
Private Sub cmdBrowse_Click()On Error Resume NextcmdBrowse.Enabled = FalseWith CommonDialog1.FileName = "*.mp3".Filter = "mp3".DialogTitle = "Pilih File Lagu".ShowOpentxtNama = .FileTitletxtNmFile.Text = .FileName 'Left(.FileTitle, Len(.FileTitle) - 4)End WithIf tambah = True Then cmdSave.Visible = True cmdTambah.Visible = FalseEnd IfEnd Sub
LAMPIRAN A-13
Private Sub cmdCari_Click()Cari = Truetambah = Falseubah = FalsecmdTambah.Enabled = FalsecmdCari.Enabled = FalsetxtKode.Locked = FalsetxtKode.SetFocusEnd Sub
Private Sub cmdHapus_Click() rsCari.Delete Set rsCari = Nothing MsgBox "Data sudah dihapus" mati bersih Segar cmdHapus.Enabled = False cmdRubah.Visible = True cmdUpdate.Visible = False cmdRubah.Enabled = False cmdTambah.Visible = True cmdTambah.Enabled = True cmdCari.Enabled = True cmdTambah.SetFocusEnd Sub
Private Sub cmdKeluar_Click()Unload MeEnd Sub
Private Sub cmdRubah_Click()ubah = TrueCari = Falsetambah = FalsecmdBrowse.Enabled = TruecmdRubah.Visible = FalsecmdUpdate.Visible = TruecmdHapus.Enabled = FalsetxtNama.Locked = FalsetxtNama.SetFocusEnd Sub
Private Sub cmdSave_Click()cmdSave.Visible = FalsecmdTambah.Visible = TrueCall SaveCall bersihCall matiCall SegarcmdTambah.SetFocusEnd Sub
Private Sub cmdTambah_Click()tambah = TrueCari = Falseubah = FalsecmdBrowse.Enabled = TruecmdTambah.Enabled = FalsecmdSave.Visible = True
LAMPIRAN A-14
cmdCari.Enabled = FalsetxtKode.Locked = FalsetxtKode.SetFocusEnd Sub
Private Sub cmdUpdate_Click()Set rsUbah = New ADODB.Recordset rsUbah.Open "Update tLagu set NmFile='" & txtNmFile.Text & "',NmLagu='" & txtNama.Text & "'where KdLagu='" & txtKode.Text & "'", CN, adOpenDynamic, adLockOptimisticubah = FalsematibersihSegarMsgBox "Data Lagu sudah di Update"cmdUpdate.Visible = FalsecmdHapus.Enabled = FalsecmdRubah.Visible = TruecmdRubah.Enabled = FalsecmdCari.Enabled = TruecmdTambah.Visible = TruecmdTambah.Enabled = TruecmdTambah.SetFocusEnd SubSub Simpan()Set rsSimpan = New ADODB.Recordset rsSimpan.Open "tLagu", CN, adOpenDynamic, adLockOptimistic rsSimpan.AddNew rsSimpan!KdLagu = txtKode.Text rsSimpan!Nmlagu = txtNama.Text rsSimpan!NmFile = txtNmFile.Text rsSimpan!UserID = frmLogON.cboUser.Text rsSimpan.UpdateEnd SubPrivate Sub Form_Activate()matibersihgrid.ColWidth(0) = 0grid.ColWidth(1) = 1000grid.ColWidth(2) = 4000grid.ColWidth(3) = 7000grid.TextMatrix(0, 0) = ""grid.TextMatrix(0, 1) = "Kode"grid.TextMatrix(0, 2) = "Nama Lagu"grid.TextMatrix(0, 3) = "Nama File"
cmdCari.Enabled = TruecmdTambah.Enabled = TruecmdRubah.Enabled = FalsecmdUpdate.Visible = FalsecmdSave.Visible = FalsecmdHapus.Enabled = FalsecmdBatal.Enabled = TruecmdBrowse.Enabled = FalsecmdTambah.SetFocusEnd Sub
Private Sub Form_Load()KoneksiEnd Sub
LAMPIRAN A-15
Sub mati()txtKode.Locked = TruetxtNama.Locked = TruetxtNmFile.Locked = True
End SubSub bersih()txtKode = ""txtNama = ""txtNmFile = ""End Sub
Sub Save() If txtKode.Text <> "" Then Set rsCari = New ADODB.Recordset rsCari.Open "Select * from tLagu where kdLagu='" & txtKode.Text & "'", CN, 1, 3 If tambah = True Then If rsCari.EOF = True Then 'txtNama.Text = CommonDialog1.FileName X = MsgBox("Mau disimpan ?", vbYesNo) If X = vbYes Then Simpan mati Segar bersih tambah = False MsgBox "Data sudah di Simpan" cmdTambah.Enabled = True cmdCari.Enabled = True cmdRubah.Enabled = False cmdTambah.SetFocus Else mati bersih tambah = False cmdTambah.Enabled = True cmdCari.Enabled = True cmdRubah.Enabled = False cmdTambah.SetFocus End If Else MsgBox "Data sudah ada" txtKode = "" txtNama = "" cmdBrowse.Enabled = True cmdBrowse.SetFocus End If End If End IfEnd Sub
Private Sub txtKode_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then If Cari = True Then Set rsCari = New ADODB.Recordset rsCari.Open "Select * from tLagu where Kata='" & txtKode.Text & "'", CN, 1, 3 If Not rsCari.EOF = True Then txtNama.Text = rsCari!NmFileSuara
LAMPIRAN A-16
cmdRubah.Enabled = True cmdHapus.Enabled = True cmdRubah.SetFocus Else MsgBox "Data tidak ada" txtKode.Text = "" txtKode.SetFocus End If End IfEnd IfEnd Sub
Private Sub txtKode_Change()If Len(txtKode) < 5 Then Exit SubElse Set rsCari = New ADODB.Recordset rsCari.Open "select * from tLagu where kdLagu='" & txtKode.Text & "'", CN, 1, 2 If tambah = True Then If Not rsCari.EOF Then MsgBox "Kode sudah ada" txtKode = "" txtKode.SetFocus Else txtNama.Locked = False txtNama.SetFocus End If ElseIf Cari = True Then If rsCari.EOF Then MsgBox "Kode tidak ada" txtKode = "" txtKode.SetFocus Else txtNama = rsCari!Nmlagu txtNmFile = rsCari!NmFile cmdRubah.Enabled = True cmdHapus.Enabled = True cmdRubah.SetFocus End If End IfEnd IfEnd Sub
Private Sub txtNama_Change()If ubah = True Then cmdRubah.Visible = False cmdHapus.Enabled = False cmdUpdate.Visible = TrueEnd IfEnd Sub
Private Sub txtNama_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then cmdBrowse.Enabled = True cmdBrowse.SetFocusEnd IfEnd Sub
LAMPIRAN A-17
6. Data User
Option ExplicitDim rsPasswd As Recordset
Private Sub cmdBatal_Click()txtUserID.Text = ""txtPasswd.Text = ""ubah = Falsetambah = FalseCari = FalsecmdRubah.Enabled = FalsecmdHapus.Enabled = FalsecmdCari.Enabled = TruecmdTambah.Enabled = TruecmdTambah.SetFocusEnd Sub
Private Sub cmdCari_Click()Cari = TruecmdTambah.Enabled = FalsecmdCari.Enabled = FalsetxtUserID.Locked = FalsetxtUserID.SetFocusEnd Sub
Private Sub cmdHapus_Click() rsCari.Delete mati bersih MsgBox "User sudah di hapus ..." cmdRubah.Visible = True cmdUpdate.Visible = False cmdRubah.Enabled = False cmdHapus.Enabled = False cmdCari.Enabled = True cmdSave.Visible = False cmdTambah.Visible = True cmdTambah.Enabled = True cmdTambah.SetFocusEnd Sub
Private Sub cmdKeluar_Click()Unload MeEnd Sub
Private Sub cmdRubah_Click()ubah = TruecmdRubah.Visible = FalsecmdHapus.Enabled = FalsecmdUpdate.Visible = TruetxtPasswd.Locked = FalsetxtPasswd.SetFocusEnd Sub
Private Sub cmdSave_Click()If tambah = True Then Call SaveEnd IfEnd Sub
LAMPIRAN A-18
Private Sub cmdTambah_Click()tambah = TruecmdTambah.Visible = FalsecmdSave.Visible = TruecmdCari.Enabled = FalsecmdCari.Enabled = FalsetxtUserID.Locked = FalsetxtUserID.SetFocusEnd Sub
Private Sub cmdUpdate_Click()If ubah = True Then Set rsUbah = New ADODB.Recordset rsUbah.Open "Update tUser Set Passwd ='" & txtPasswd.Text & "' where UserID ='" & txtUserID.Text & "'", CN, adOpenDynamic, adLockOptimistic MsgBox "Data sudah Ubah" ubah = False mati bersih cmdRubah.Visible = True cmdUpdate.Visible = False cmdRubah.Enabled = False cmdHapus.Enabled = False cmdCari.Enabled = True cmdSave.Visible = False cmdTambah.Visible = True cmdTambah.Enabled = True cmdTambah.SetFocusEnd IfEnd Sub
Private Sub Form_Activate()txtUserID.Locked = TruetxtPasswd.Text = ""txtUserID.Text = ""ubah = Falsetambah = FalseCari = FalsecmdRubah.Visible = TruecmdRubah.Enabled = FalsecmdUpdate.Visible = FalsecmdHapus.Enabled = FalsecmdCari.Enabled = TruecmdTambah.Visible = TruecmdSave.Visible = FalsecmdTambah.Enabled = TruecmdTambah.SetFocusEnd SubSub mati()txtUserID.Locked = TruetxtPasswd.Locked = TrueEnd SubSub bersih()txtUserID.Text = ""txtPasswd.Text = ""End Sub
LAMPIRAN A-19
Private Sub Form_Load()KoneksiEnd Sub
Private Sub txtpasswd_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then If tambah = True Then cmdSave.Visible = True cmdTambah.Visible = False cmdSave.SetFocus ElseIf ubah = True Then cmdRubah.Enabled = True cmdRubah.SetFocus End IfEnd IfEnd SubSub Save() Set rsPasswd = New ADODB.Recordset rsPasswd.Open "Select * from tUser where UserID='" & txtUserID.Text & "' and Passwd='" & txtPasswd.Text & "'", CN, adOpenDynamic, adLockOptimistic If tambah = True Then If rsPasswd.EOF = True Then Set rsSimpan = New ADODB.Recordset rsSimpan.Open "select * from tUser", CN, adOpenDynamic, adLockOptimistic rsSimpan.AddNew rsSimpan.Fields("UserID") = txtUserID.Text rsSimpan.Fields("Passwd") = txtPasswd.Text rsSimpan.Update mati bersih MsgBox "Data sudah tersimpan" tambah = False cmdRubah.Visible = True cmdUpdate.Visible = False cmdRubah.Enabled = False cmdHapus.Enabled = False cmdCari.Enabled = True cmdSave.Visible = False cmdTambah.Visible = True cmdTambah.Enabled = True cmdTambah.SetFocus Else MsgBox "User sudah ada ..." txtPasswd.Text = "" txtUserID.Text = "" txtUserID.SetFocus End If End If
End Sub
Private Sub txtUserId_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then If tambah = True Then Set rsCari = New ADODB.Recordset rsCari.Open "Select * from tUser where UserID='" & txtUserID.Text & "'", CN, adOpenDynamic, adLockOptimistic
LAMPIRAN A-20
If rsCari.EOF = True Then txtPasswd.Locked = False txtPasswd.SetFocus Else MsgBox "User sudah ada ..." txtUserID.Text = "" txtPasswd.Text = "" txtUserID.SetFocus End If ElseIf Cari = True Then Set rsCari = New ADODB.Recordset rsCari.Open "Select * from tUser where UserID='" & txtUserID.Text & "'", CN, adOpenDynamic, adLockOptimistic If rsCari.EOF = True Then MsgBox "User belum ada ..." txtUserID.Text = "" txtUserID.SetFocus Else txtPasswd.Text = rsCari.Fields("Passwd") cmdRubah.Enabled = True cmdHapus.Enabled = True cmdRubah.SetFocus End If End IfEnd IfEnd Sub
7.About
Private Sub cmdKeluar_Click() Unload frmAboutEnd Sub
8. Module-1(modPlayer)
Option Explicit
Private Const BIF_STATUSTEXT = &H4&Private Const BIF_RETURNONLYFSDIRS = 1Private Const BIF_DONTGOBELOWDOMAIN = 2Private Const MAX_PATH = 260
Private Const WM_USER = &H400Private Const BFFM_INITIALIZED = 1Private Const BFFM_SELCHANGED = 2Private Const BFFM_SETSTATUSTEXT = (WM_USER + 100)Private Const BFFM_SETSELECTION = (WM_USER + 102)
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As LongPrivate Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As LongPrivate Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As LongPrivate Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
LAMPIRAN A-21
Private Type BrowseInfo hWndOwner As Long pIDLRoot As Long pszDisplayName As Long lpszTitle As Long ulFlags As Long lpfnCallback As Long lParam As Long iImage As LongEnd Type
Private m_CurrentDirectory As String Public Function BrowseForFolder(owner As Form, Title As String, StartDir As String) As String Dim lpIDList As Long Dim szTitle As String Dim sBuffer As String Dim tBrowseInfo As BrowseInfo m_CurrentDirectory = StartDir & vbNullChar
szTitle = Title With tBrowseInfo .hWndOwner = owner.hwnd .lpszTitle = lstrcat(szTitle, "") .ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN + BIF_STATUSTEXT .lpfnCallback = GetAddressofFunction(AddressOf _BrowseCallbackProc) 'get address of function. End With
lpIDList = SHBrowseForFolder(tBrowseInfo) If (lpIDList) Then sBuffer = Space(MAX_PATH) SHGetPathFromIDList lpIDList, sBuffer sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1) BrowseForFolder = sBuffer Else BrowseForFolder = "" End IfEnd Function Private Function BrowseCallbackProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal lp As Long, ByVal pData As Long) As Long Dim lpIDList As Long Dim ret As Long Dim sBuffer As String On Error Resume Next Select Case uMsg Case BFFM_INITIALIZED Call SendMessage(hwnd, BFFM_SETSELECTION, 1,_ m_CurrentDirectory) Case BFFM_SELCHANGED sBuffer = Space(MAX_PATH) ret = SHGetPathFromIDList(lp, sBuffer) If ret = 1 Then Call SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, sBuffer) End If End Select
LAMPIRAN A-22
BrowseCallbackProc = 0End FunctionPrivate Function GetAddressofFunction(add As Long) As Long GetAddressofFunction = addEnd Function
9. Module-2 (ModRequest)
Option ExplicitGlobal CN As ConnectionPublic tambah As BooleanPublic Cari As BooleanPublic ubah As BooleanPublic X As StringPublic rsSimpan As RecordsetPublic rsSimpan1 As RecordsetPublic rsCari As RecordsetPublic rsUbah As RecordsetPublic rsHapus As RecordsetPublic rsStatus As RecordsetPublic rsUpdate As RecordsetPublic rsSegar As RecordsetGlobal Const SND_ASYNC = &H1, SND_NOSTOP = &H10Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As IntegerDeclare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As Long) As LongPublic Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _ (ByVal lpstrCommand As String, _ ByVal lpstrReturnString As String, _ ByVal uReturnLength As Long, _ ByVal hwndCallback As Long) As LongPublic Sub Koneksi()Set CN = New ADODB.ConnectionCN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\dbSMSRequest.mdb;Persist Security Info=False"CN.OpenEnd Sub
10. Module-3 (Module1)
Option ExplicitPublic location As StringPublic MusicName As StringPublic moving As BooleanPublic currentduration As IntegerPublic autoloading As BooleanPublic currentlyplaying As StringPublic PButton As SinglePublic CTime As StringPublic Activated As Boolean
LAMPIRAN A-23
Public Sub SaveFile()Dim FR As IntegerDim Line As StringDim i As IntegerDim Max As IntegerFR = FreeFilei = 0Max = MainForm.Music.ListCount
Open App.Path & "\Uploaded Music.J34" For Output As #FRDo While i < MaxPrint #FR, MainForm.PathList.List(i)i = i + 1LoopClose #FREnd Sub
Public Function ReadFile() As StringOn Error GoTo BlankFileDim FR As IntegerDim FileContents As StringDim FileLineFR = FreeFileDo While Not EOF(FR)Line Input #FR, FileLineFileContents = FileContents & vbNewLine & FileLineLoopClose #FRReadFile = FileContentsExit FunctionBlankFile:ReadFile = ""End FunctionPublic Sub ConvertMinuets(ByVal Sec As Integer)If Sec Mod 60 = 0 ThenCTime = Sec \ 60ElseCTime = Sec \ 60 & " " & Sec Mod 60End IfEnd Sub
Public Sub Play()MainForm.WindowsMediaPlayer1.Controls.PlayDim mlength As IntegerDim mstring As Stringmlength = Len(MusicName)mstring = Right(MusicName, 3)If mstring = ".wm" Then MusicName = VBA.Strings.Left(MusicName, mlength - 3)Else mstring = Right(MusicName, 4) If mstring = ".mp3" Or mstring = ".asf" Or mstring = ".wma" Or mstring = ".wav" Or mstring = ".snd" Then MusicName = VBA.Strings.Left(MusicName, mlength - 4) End IfEnd IfIf (currentlyplaying = "") = False Then MusicName = currentlyplayingMainForm.Caption = MusicNameIf InTray = False Then MainForm.pausebutton.SetFocusEnd Sub
LAMPIRAN A-24
Public Sub Pause()MainForm.WindowsMediaPlayer1.Controls.PauseEnd Sub
Public Sub StopSong()MainForm.WindowsMediaPlayer1.Controls.StopEnd Sub
Public Sub MusicClick()Dim mlength As IntegerDim mstring As StringMusicName = MainForm.Music.TextMainForm.PathList.List(MainForm.Music.ListIndex)MainForm.WindowsMediaPlayer1.URL = MainForm.lblNmFile MainForm.Caption = ""mlength = Len(MusicName)mstring = Right(MusicName, 3)
If mstring = ".wm" Then MusicName = VBA.Strings.Left(MusicName, mlength - 3)Else mstring = Right(MusicName, 4) If mstring = ".mp3" Or mstring = ".asf" Or mstring = ".wma" Or mstring = ".wav" Or mstring = ".snd" Then MusicName = VBA.Strings.Left(MusicName, mlength - 4) End IfEnd If
MainForm.Caption = MusicNameMainForm.WindowsMediaPlayer1.Controls.Playcurrentduration = MainForm.WindowsMediaPlayer1.currentMedia.durationMainForm.Timer1.Enabled = FalseMainForm.Timer1.Enabled = TrueMainForm.leftlabel.Caption = "0"MainForm.playbutton.Enabled = FalseMainForm.pausebutton.Enabled = TrueMainForm.stopbutton.Enabled = Truecurrentlyplaying = MusicName
If InTray = True ThenCall ModifyIcon(MainForm, currentlyplaying)End IfEnd Sub
11. Module-4 (TrayModule)
Public Declare Function Shell_NotifyIconA Lib "shell32.dll" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As IntegerConst NIM_ADD = &H0Const NIM_MODIFY = &H1Const NIM_DELETE = &H2Const NIF_MESSAGE = &H1Const NIF_ICON = &H2Const NIF_TIP = &H4Public Const WM_LBUTTONDOWN = &H201Public Const WM_RBUTTONDOWN = &H204Public Const WM_LBUTTONDBLCLK = &H203
LAMPIRAN A-25
Public Type NOTIFYICONDATA cbSize As Long hwnd As Long uID As Long uFlags As Long uCallbackMessage As Long hIcon As Long szTip As String * 64End TypePublic InTray As Boolean
Public Sub AddIcon(TargetForm As Form, ToolTip As String)Dim AddIconData As NOTIFYICONDATA
With AddIconData.cbSize = Len(AddIconData).hIcon = TargetForm.Icon.hwnd = TargetForm.hwnd.szTip = ToolTip & vbNullChar.uCallbackMessage = WM_LBUTTONDOWN.uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP.uID = vbNullEnd With
Call Shell_NotifyIconA(NIM_ADD, AddIconData)InTray = TrueEnd Sub
Public Sub ModifyIcon(TargetForm As Form, ToolTip As String)Dim AddIconData As NOTIFYICONDATA
With AddIconData.cbSize = Len(AddIconData).hIcon = TargetForm.Icon.hwnd = TargetForm.hwnd.szTip = ToolTip & vbNullChar.uCallbackMessage = WM_LBUTTONDOWN.uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP.uID = vbNullEnd With
Call Shell_NotifyIconA(NIM_MODIFY, AddIconData)InTray = TrueEnd Sub
Public Sub DeleteIcon(TargetForm As Form)Dim AddIconData As NOTIFYICONDATA
With AddIconData.cbSize = Len(AddIconData).hIcon = vbNull.hwnd = TargetForm.hwnd.szTip = "" & vbNullChar.uCallbackMessage = vbNull.uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP.uID = vbNullEnd WithCall Shell_NotifyIconA(NIM_DELETE, AddIconData)InTray = FalseEnd Sub