SlideShare une entreprise Scribd logo
1  sur  25
LAMPIRAN A-1



                              LISTING PROGRAM

1. Login

Option Explicit
Dim rsUser As Recordset

Private Sub cboUser_Click()
    txtPass.Locked = False
    txtPass.SetFocus
End Sub

Private Sub cmdCancel_Click()
End
End Sub

Private Sub cmdOK_Click()
On Error Resume Next
Set 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 If
End Sub

Private Sub Form_Activate()
txtPass = ""
cboUser = ""
cboUser.SetFocus
End Sub
Private Sub Form_Load()
Koneksi
Set rsUser = New ADODB.Recordset
rsUser.Open "Select * from tUser order by           UserId   asc",   CN,
adOpenDynamic, adLockOptimistic
Do Until rsUser.EOF = True
cboUser.AddItem rsUser.Fields("UserId")
rsUser.MoveNext
Loop
End Sub
Private Sub txtPass_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
     cmdOk.Enabled = True
     cmdOk.SetFocus
End If
End Sub
Private Sub cboUser_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
     txtPass.Locked = False
     txtPass.SetFocus
End If
End Sub
LAMPIRAN A-2



2. Menu Utama


Private Sub cmdAbout_Click()
frmAbout.Show
End Sub

Private Sub cmdQuit_Click()
End
End Sub

Private Sub cmdReq_Click()
MainForm.Show
End Sub

Private Sub cmdUtil_Click()
frmMenuADM.Show
End Sub

Private Sub Form_Activate()
Timer1.Enabled = True
End Sub


3.Request

Dim rsLagu As Recordset
Dim KdLagu As String
Dim IDRequest As Integer

Private Sub cmdQuit_Click()
If InTray = True Then
Call TrayModule.DeleteIcon(MainForm)
End If
Unload Me
Unload AddForm
End Sub

Private Sub cmdStart_Click()
cmdStart.Enabled = False
Call Start
End Sub
Sub 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 = Nothing
Set rsCari = New ADODB.Recordset
        rsCari.Open "Update tDatarequest     SET   stPutar=    '*'   where
idrequest=" & IDRequest & "", CN, 1, 2
Set rsCari = Nothing
End Sub

Private Sub Command1_Click()
AddForm.Show
End Sub

Private Sub Command2_Click()
On Error GoTo skip
Dim Selected As Integer
MusicName = Music.Text
Selected = Music.ListIndex
Music.RemoveItem (Selected)
PathList.RemoveItem (Selected)
Module1.SaveFile
Play2action.Enabled = True
Timer1.Enabled = False
leftlabel.Caption = "0"
Playaction.Enabled = True
pauseaction.Enabled = False
pausebutton.Enabled = False
stopbutton.Enabled = False
stopaction.Enabled = False
Exit Sub
End Sub

Private Sub deleteaction_Click()
On Error GoTo skip
MusicName = Music.Text
Music.RemoveItem (Music.ListIndex)
WindowsMediaPlayer1.Controls.Stop
playbutton.Enabled = True
Playaction.Enabled = True
Play2action.Enabled = True
Exit Sub
End 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 If
End If
End 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 If
End Sub

Private Sub Music_Click()
If Music.ListCount > 0 Then
    Module1.MusicClick
End If
End Sub

Private Sub Music_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Button = 1 Then
Module1.MusicClick
ElseIf Button = 2 Then
PopupMenu musicmenu
End If
End Sub

Private Sub Music_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Music.ToolTipText = MusicName
End Sub

Private Sub NextAction_Click()
Call TrayNext_Click
End Sub

Private Sub OrderAction_Click()
Dim MusicName As String
Dim MusicPath As String
Dim i, j, k As Integer
Dim Index1, Index2 As Integer
Dim Letter1, Letter2 As String
Dim OldCaption As String
OldCaption = Me.Caption
Me.Caption = "Ordering..."
LAMPIRAN A-5



If Music.ListCount >= 2 Then
i = Music.ListCount - 2
Do While i > -1
j = 1

Compare:
Letter1 = UCase(Mid(Music.List(i), j, 1))
Letter2 = UCase(Mid(Music.List(i + 1), j, 1))

    If Letter2 < Letter1 Then
Switch:
    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 If
Cont:
i = i - 1
Loop
End If
Me.Caption = OldCaption
End Sub

Private Sub Play2action_Click()
Module1.Play
End Sub

Private Sub playbutton_Click()
playbutton.Enabled = True
Module1.Play
End Sub

Private Sub pausebutton_Click()
Module1.Pause
End Sub
Private Sub playmenu_Click()
If Music.ListCount > 0 Then
NextAction.Enabled = True
BackAction.Enabled = True
End If
End Sub
LAMPIRAN A-6



Private Sub SendToTray_Click()
If InTray = False Then
Me.Hide
 Call TrayModule.AddIcon(MainForm, currentlyplaying)
 End If
End Sub

Private Sub ShowAction_Click()
If InTray = True Then
MainForm.Show
Call TrayModule.DeleteIcon(MainForm)
End If
End Sub

Private Sub ShuffleAction_Click()
Dim Songs As Integer
Dim i As Integer
Dim NewPos As Integer
Dim Name1 As String
Dim Name2 As String
Dim Path1, Path2 As String
Dim Taken() As Integer
Randomize
Songs = Music.ListCount
ReDim Taken(Songs) As Integer
i = 0

Do While i < Songs
Taken(i) = 0
i = i + 1
Loop

i = 0
Do While i < Songs
If Taken(i) = 0 Then
NewPos = (Rnd * (Songs - 2)) + 1
Taken(i) = 1
Taken(NewPos) = 1
Name1 = Music.List(i)
Path1 = PathList.List(i)
Name2 = Music.List(NewPos)
Path2 = PathList.List(NewPos)
Music.List(i) = Name2
PathList.List(i) = Path2
Music.List(NewPos) = Name1
PathList.List(NewPos) = Path1
End If
i = i + 1
Loop
Music.Refresh
End Sub

Private Sub Slider1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 37 Then
On Error GoTo skip
moving = True
End If
Exit Sub
skip:
End Sub
LAMPIRAN A-7



Private Sub Slider1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 37 Then
On Error GoTo skip
WindowsMediaPlayer1.Controls.currentPosition = Slider1.Value
leftlabel.Caption = Slider1.Value
moving = False
End If
Exit Sub
skip:
End Sub

Private Sub Slider1_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)
On Error GoTo skip
If Button = 1 Then
moving = True
PButton = 1
Else
PButton = 2
End If
Exit Sub
skip:
End Sub

Private Sub Slider1_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
On Error GoTo skip
If PButton = 1 Then
WindowsMediaPlayer1.Controls.currentPosition = Slider1.Value
leftlabel.Caption = Slider1.Value
moving = False
End If
Exit Sub
skip:
End Sub

Private Sub stopbutton_Click()
Module1.StopSong
playbutton.Enabled = True
End Sub

Private Sub Cover_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Button = 2 Then
PopupMenu playmenu
End If
End Sub
Sub Segar()
Set rsCari = New ADODB.Recordset
    rsCari.Open "Select * from tDataRequest order by IdRequest asc",
CN, 1, 2
Adodc1.Refresh
grid.Refresh
grid.ColWidth(0) = 0
grid.ColWidth(1) = 1000
grid.ColWidth(2) = 1000
grid.ColWidth(3) = 1200
grid.ColWidth(4) = 1200
grid.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 = Nothing
End Sub
Private Sub Form_Activate()
Call Segar
End Sub

Private Sub Form_Load()
Koneksi
Dim FR As Integer
Dim FullName As String
Dim i As Integer
Dim DirName As String
FR = FreeFile

Music.Clear
PathList.Clear
VolumeControl.Value = WindowsMediaPlayer1.Settings.Volume
leftlabel.Caption = "-1"
moving = False
autoloading = 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 #FR
exitloop:
    autoloading = False
    currentlyplaying = ""
    Call OrderAction_Click
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
If InTray = True Then
Call TrayModule.DeleteIcon(MainForm)
End If
Unload Me
Unload AddForm
End Sub

Private Sub minaction_Click()
MainForm.WindowState = 1
Unload AddForm
End Sub

Private Sub pauseaction_Click()
Module1.Pause
End Sub
LAMPIRAN A-9



Private Sub playaction_Click()
Module1.Play
End Sub

Private Sub quitaction_Click()
Unload Me
Unload AddForm
End Sub

Private Sub Stopaction_Click()
Module1.StopSong
End Sub

Private Sub Timer1_Timer()
leftlabel.Caption = leftlabel.Caption + 1
If leftlabel.Caption >= WindowsMediaPlayer1.currentMedia.duration And
WindowsMediaPlayer1.currentMedia.duration > 0 Then
On Error GoTo restart
Music.ListIndex = Music.ListIndex + 1
leftlabel.Caption = "0"
End If
Timer1.Enabled = False
Timer1.Enabled = True
If moving = False Then
Timer2.Enabled = True
Slider1.Value = WindowsMediaPlayer1.Controls.currentPosition
End If
Module1.ConvertMinuets (Slider1.Value)
Dim temp As String
temp = CTime
Module1.ConvertMinuets (WindowsMediaPlayer1.currentMedia.duration)
Slider1.ToolTipText = temp & "/" & CTime
Exit Sub
restart: Music.ListIndex = 0
leftlabel.Caption = "0"
End Sub

Private Sub Timer2_Timer()
On Error GoTo atempt
currentduration = WindowsMediaPlayer1.currentMedia.duration
Slider1.Max = currentduration
Timer2.Enabled = False
Exit Sub
atempt: currentduration = WindowsMediaPlayer1.currentMedia.duration
If currentduration > 0 Then Slider1.Max = currentduration
Timer2.Enabled = False
End Sub

Private Sub TrayBack_Click()
On Error GoTo 1
If Music.ListIndex > 0 Then
Music.ListIndex = Music.ListIndex - 1
Else
GoTo 1
End If
Exit Sub
1: Music.ListIndex = Music.ListCount - 1
End Sub
LAMPIRAN A-10



Private Sub TrayExit_Click()
Unload Me
Unload AddForm
End Sub

Private Sub TrayMenu_Click()
If playbutton.Enabled = True Then
TrayPlay.Enabled = True
Else
TrayPlay.Enabled = False
End If

If pausebutton.Enabled = True Then
TrayPause.Enabled = True
Else
TrayPause.Enabled = False
End If

If stopbutton.Enabled = True Then
TrayStop.Enabled = True
Else
TrayStop.Enabled = False
End If

If Music.ListCount   > 0 Then
TrayNext.Enabled =   True
TrayBack.Enabled =   True
Else
TrayNext.Enabled =   False
TrayBack.Enabled =   False
End If
End Sub

Private Sub TrayNext_Click()
On Error GoTo 1
Music.ListIndex = Music.ListIndex + 1
Exit Sub
1: Music.ListIndex = 0
End Sub

Private Sub TrayPause_Click()
Module1.Pause
End Sub

Private Sub TrayPlay_Click()
Module1.Play
End Sub

Private Sub TrayStop_Click()
Module1.StopSong
End Sub

Private Sub Unload2action_Click()
On Error GoTo skip
Dim i
For 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 = True
Playaction.Enabled = True
Play2action.Enabled = False
leftlabel.Caption = "0"
stopbutton.Enabled = False
stopaction.Enabled = False
pausebutton.Enabled = False
pauseaction.Enabled = False
    End If
Next i
Exit Sub
skip:
End Sub

Private Sub unloadaction_Click()
Music.Clear
Timer1.Enabled = False
WindowsMediaPlayer1.Controls.Stop
leftlabel.Caption = "0"
playbutton.Enabled = False
Playaction.Enabled = False
Play2action.Enabled = False
stopbutton.Enabled = False
stopaction.Enabled = False
pausebutton.Enabled = False
pauseaction.Enabled = False
Me.Caption = "J34 Media Player"
End Sub

Private Sub VolumeControl_Change()
WindowsMediaPlayer1.Settings.Volume = VolumeControl.Value
End Sub

Private Sub VolumeControl_MouseMove(Button As     Integer,     Shift   As
Integer, X As Single, Y As Single)
VolumeControl.ToolTipText = VolumeControl.Value
End Sub

Private Sub WindowsMediaPlayer1_MouseDown(ByVal nButton As Integer,
ByVal nShiftState As Integer, ByVal fX As Long, ByVal fY As Long)
If nButton = 2 Then
PopupMenu playmenu
End If
End Sub

4. Menu Utility

Private Sub cmdLagu_Click()
frmLagu.Show
End Sub

Private Sub cmdUser_Click()
frmUser.Show
End Sub

Private Sub cmdKeluar_Click()
Me.Hide
Unload Me
frmUtama.Show
End Sub
LAMPIRAN A-12



Private Sub Form_Unload(Cancel As Integer)
Me.Hide
Unload Me
frmUtama.Show
End Sub

5. Data Lagu

Option Explicit
Dim rsKata As Recordset
Sub Segar()
Set rsCari = New ADODB.Recordset
    rsCari.Open "Select * from tLagu order by KdLagu asc", CN, 1, 2
Adodc1.Refresh
grid.Refresh
grid.ColWidth(0) = 0
grid.ColWidth(1) = 1000
grid.ColWidth(2) = 4000
grid.ColWidth(3) = 7000
grid.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()
mati
bersih
tambah = False
Cari = False
ubah = False
cmdTambah.Enabled = True
cmdCari.Enabled = True
cmdRubah.Visible = True
cmdRubah.Enabled = False
cmdUpdate.Visible = False
cmdHapus.Enabled = False
cmdBatal.Enabled = True
cmdTambah.Visible = True
cmdTambah.Enabled = True
cmdSave.Visible = False
cmdTambah.SetFocus
End Sub

Private Sub cmdBrowse_Click()
On Error Resume Next
cmdBrowse.Enabled = False
With CommonDialog1
.FileName = "*.mp3"
.Filter = "mp3"
.DialogTitle = "Pilih File Lagu"
.ShowOpen
txtNama = .FileTitle
txtNmFile.Text = .FileName 'Left(.FileTitle, Len(.FileTitle) - 4)
End With
If tambah = True Then
    cmdSave.Visible = True
    cmdTambah.Visible = False
End If
End Sub
LAMPIRAN A-13



Private Sub cmdCari_Click()
Cari = True
tambah = False
ubah = False
cmdTambah.Enabled = False
cmdCari.Enabled = False
txtKode.Locked = False
txtKode.SetFocus
End 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.SetFocus
End Sub

Private Sub cmdKeluar_Click()
Unload Me
End Sub

Private Sub cmdRubah_Click()
ubah = True
Cari = False
tambah = False
cmdBrowse.Enabled = True
cmdRubah.Visible = False
cmdUpdate.Visible = True
cmdHapus.Enabled = False
txtNama.Locked = False
txtNama.SetFocus
End Sub

Private Sub cmdSave_Click()
cmdSave.Visible = False
cmdTambah.Visible = True
Call Save
Call bersih
Call mati
Call Segar
cmdTambah.SetFocus
End Sub

Private Sub cmdTambah_Click()
tambah = True
Cari = False
ubah = False
cmdBrowse.Enabled = True
cmdTambah.Enabled = False
cmdSave.Visible = True
LAMPIRAN A-14



cmdCari.Enabled = False
txtKode.Locked = False
txtKode.SetFocus
End 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, adLockOptimistic
ubah = False
mati
bersih
Segar
MsgBox "Data Lagu sudah di Update"
cmdUpdate.Visible = False
cmdHapus.Enabled = False
cmdRubah.Visible = True
cmdRubah.Enabled = False
cmdCari.Enabled = True
cmdTambah.Visible = True
cmdTambah.Enabled = True
cmdTambah.SetFocus
End Sub
Sub 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.Update
End Sub
Private Sub Form_Activate()
mati
bersih
grid.ColWidth(0) = 0
grid.ColWidth(1) = 1000
grid.ColWidth(2) = 4000
grid.ColWidth(3) = 7000
grid.TextMatrix(0, 0) = ""
grid.TextMatrix(0, 1) = "Kode"
grid.TextMatrix(0, 2) = "Nama Lagu"
grid.TextMatrix(0, 3) = "Nama File"

cmdCari.Enabled = True
cmdTambah.Enabled = True
cmdRubah.Enabled = False
cmdUpdate.Visible = False
cmdSave.Visible = False
cmdHapus.Enabled = False
cmdBatal.Enabled = True
cmdBrowse.Enabled = False
cmdTambah.SetFocus
End Sub

Private Sub Form_Load()
Koneksi
End Sub
LAMPIRAN A-15



Sub mati()
txtKode.Locked = True
txtNama.Locked = True
txtNmFile.Locked = True

End Sub
Sub 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 If
End 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 If
End If
End Sub

Private Sub txtKode_Change()
If Len(txtKode) < 5 Then
     Exit Sub
Else
     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 If
End If
End Sub

Private Sub txtNama_Change()
If ubah = True Then
    cmdRubah.Visible = False
    cmdHapus.Enabled = False
    cmdUpdate.Visible = True
End If
End Sub

Private Sub txtNama_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    cmdBrowse.Enabled = True
    cmdBrowse.SetFocus
End If
End Sub
LAMPIRAN A-17



6. Data User

Option Explicit
Dim rsPasswd As Recordset

Private Sub cmdBatal_Click()
txtUserID.Text = ""
txtPasswd.Text = ""
ubah = False
tambah = False
Cari = False
cmdRubah.Enabled = False
cmdHapus.Enabled = False
cmdCari.Enabled = True
cmdTambah.Enabled = True
cmdTambah.SetFocus
End Sub

Private Sub cmdCari_Click()
Cari = True
cmdTambah.Enabled = False
cmdCari.Enabled = False
txtUserID.Locked = False
txtUserID.SetFocus
End 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.SetFocus
End Sub

Private Sub cmdKeluar_Click()
Unload Me
End Sub

Private Sub cmdRubah_Click()
ubah = True
cmdRubah.Visible = False
cmdHapus.Enabled = False
cmdUpdate.Visible = True
txtPasswd.Locked = False
txtPasswd.SetFocus
End Sub

Private Sub cmdSave_Click()
If tambah = True Then
    Call Save
End If
End Sub
LAMPIRAN A-18



Private Sub cmdTambah_Click()
tambah = True
cmdTambah.Visible = False
cmdSave.Visible = True
cmdCari.Enabled = False
cmdCari.Enabled = False
txtUserID.Locked = False
txtUserID.SetFocus
End 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.SetFocus
End If
End Sub

Private Sub Form_Activate()
txtUserID.Locked = True
txtPasswd.Text = ""
txtUserID.Text = ""
ubah = False
tambah = False
Cari = False
cmdRubah.Visible = True
cmdRubah.Enabled = False
cmdUpdate.Visible = False
cmdHapus.Enabled = False
cmdCari.Enabled = True
cmdTambah.Visible = True
cmdSave.Visible = False
cmdTambah.Enabled = True
cmdTambah.SetFocus
End Sub
Sub mati()
txtUserID.Locked = True
txtPasswd.Locked = True
End Sub
Sub bersih()
txtUserID.Text = ""
txtPasswd.Text = ""
End Sub
LAMPIRAN A-19



Private Sub Form_Load()
Koneksi
End 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 If
End If
End Sub
Sub 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 If
End If
End Sub

7.About


Private Sub cmdKeluar_Click()
    Unload frmAbout
End Sub

8. Module-1(modPlayer)

Option Explicit

Private   Const   BIF_STATUSTEXT = &H4&
Private   Const   BIF_RETURNONLYFSDIRS = 1
Private   Const   BIF_DONTGOBELOWDOMAIN = 2
Private   Const   MAX_PATH = 260

Private   Const   WM_USER = &H400
Private   Const   BFFM_INITIALIZED = 1
Private   Const   BFFM_SELCHANGED = 2
Private   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 Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As
BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal
pidList As Long, ByVal lpBuffer As String) As Long
Private 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 Long
End 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 If
End 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 = 0
End Function
Private Function GetAddressofFunction(add As Long) As Long
  GetAddressofFunction = add
End Function

9. Module-2 (ModRequest)


Option Explicit
Global CN As Connection
Public tambah As Boolean
Public Cari As Boolean
Public ubah As Boolean
Public X As String
Public rsSimpan As Recordset
Public rsSimpan1 As Recordset
Public rsCari As Recordset
Public rsUbah As Recordset
Public rsHapus As Recordset
Public rsStatus As Recordset
Public rsUpdate As Recordset
Public rsSegar As Recordset
Global Const SND_ASYNC = &H1, SND_NOSTOP = &H10
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As
Integer
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
        (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public   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 Long
Public Sub Koneksi()
Set CN = New ADODB.Connection
CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& App.Path & "dbSMSRequest.mdb;Persist Security Info=False"
CN.Open
End Sub


10.   Module-3 (Module1)

Option   Explicit
Public   location As String
Public   MusicName As String
Public   moving As Boolean
Public   currentduration As Integer
Public   autoloading As Boolean
Public   currentlyplaying As String
Public   PButton As Single
Public   CTime As String
Public   Activated As Boolean
LAMPIRAN A-23



Public Sub SaveFile()
Dim FR As Integer
Dim Line As String
Dim i As Integer
Dim Max As Integer
FR = FreeFile
i = 0
Max = MainForm.Music.ListCount

Open App.Path & "Uploaded Music.J34" For Output As #FR
Do While i < Max
Print #FR, MainForm.PathList.List(i)
i = i + 1
Loop
Close #FR
End Sub

Public Function ReadFile() As String
On Error GoTo BlankFile
Dim FR As Integer
Dim FileContents As String
Dim FileLine
FR = FreeFile
Do While Not EOF(FR)
Line Input #FR, FileLine
FileContents = FileContents & vbNewLine & FileLine
Loop
Close #FR
ReadFile = FileContents
Exit Function
BlankFile:
ReadFile = ""
End Function
Public Sub ConvertMinuets(ByVal Sec As Integer)
If Sec Mod 60 = 0 Then
CTime = Sec  60
Else
CTime = Sec  60 & " " & Sec Mod 60
End If
End Sub

Public Sub Play()
MainForm.WindowsMediaPlayer1.Controls.Play
Dim mlength As Integer
Dim mstring As String
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 If
End If
If (currentlyplaying = "") = False Then MusicName = currentlyplaying
MainForm.Caption = MusicName
If InTray = False Then MainForm.pausebutton.SetFocus
End Sub
LAMPIRAN A-24



Public Sub Pause()
MainForm.WindowsMediaPlayer1.Controls.Pause
End Sub

Public Sub StopSong()
MainForm.WindowsMediaPlayer1.Controls.Stop
End Sub

Public Sub MusicClick()
Dim mlength As Integer
Dim mstring As String
MusicName = MainForm.Music.Text
MainForm.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 If
End If

MainForm.Caption = MusicName
MainForm.WindowsMediaPlayer1.Controls.Play
currentduration = MainForm.WindowsMediaPlayer1.currentMedia.duration
MainForm.Timer1.Enabled = False
MainForm.Timer1.Enabled = True
MainForm.leftlabel.Caption = "0"
MainForm.playbutton.Enabled = False
MainForm.pausebutton.Enabled = True
MainForm.stopbutton.Enabled = True
currentlyplaying = MusicName

If InTray = True Then
Call ModifyIcon(MainForm, currentlyplaying)
End If
End Sub

11. Module-4 (TrayModule)

Public Declare Function Shell_NotifyIconA Lib "shell32.dll" (ByVal
dwMessage As Long, lpData As NOTIFYICONDATA) As Integer
Const NIM_ADD = &H0
Const NIM_MODIFY = &H1
Const NIM_DELETE = &H2
Const NIF_MESSAGE = &H1
Const NIF_ICON = &H2
Const NIF_TIP = &H4
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_RBUTTONDOWN = &H204
Public 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 * 64
End Type
Public 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 = vbNull
End With

Call Shell_NotifyIconA(NIM_ADD, AddIconData)
InTray = True
End 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 = vbNull
End With

Call Shell_NotifyIconA(NIM_MODIFY, AddIconData)
InTray = True
End 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 = vbNull
End With
Call Shell_NotifyIconA(NIM_DELETE, AddIconData)
InTray = False
End Sub

Contenu connexe

Tendances

python chapter 1
python chapter 1python chapter 1
python chapter 1Raghu nath
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2Raghu nath
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
 
The Ring programming language version 1.6 book - Part 48 of 189
The Ring programming language version 1.6 book - Part 48 of 189The Ring programming language version 1.6 book - Part 48 of 189
The Ring programming language version 1.6 book - Part 48 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 35 of 196
The Ring programming language version 1.7 book - Part 35 of 196The Ring programming language version 1.7 book - Part 35 of 196
The Ring programming language version 1.7 book - Part 35 of 196Mahmoud Samir Fayed
 
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...PROIDEA
 
Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)
Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)
Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)Tobias Pfeiffer
 
Closure, Higher-order function in Swift
Closure, Higher-order function in SwiftClosure, Higher-order function in Swift
Closure, Higher-order function in SwiftSeongGyu Jo
 
A Skeptics guide to functional style javascript
A Skeptics guide to functional style javascriptA Skeptics guide to functional style javascript
A Skeptics guide to functional style javascriptjonathanfmills
 
Ciklum net sat12112011-alexander fomin-expressions and all, all, all
Ciklum net sat12112011-alexander fomin-expressions and all, all, allCiklum net sat12112011-alexander fomin-expressions and all, all, all
Ciklum net sat12112011-alexander fomin-expressions and all, all, allCiklum Ukraine
 
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...Matt Harrison
 
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...Matt Harrison
 
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
Elixir  -Tolerância a Falhas para Adultos - GDG CampinasElixir  -Tolerância a Falhas para Adultos - GDG Campinas
Elixir -Tolerância a Falhas para Adultos - GDG CampinasFabio Akita
 

Tendances (20)

Pure kotlin
Pure kotlinPure kotlin
Pure kotlin
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
 
Into Clojure
Into ClojureInto Clojure
Into Clojure
 
The Ring programming language version 1.6 book - Part 48 of 189
The Ring programming language version 1.6 book - Part 48 of 189The Ring programming language version 1.6 book - Part 48 of 189
The Ring programming language version 1.6 book - Part 48 of 189
 
The Ring programming language version 1.7 book - Part 35 of 196
The Ring programming language version 1.7 book - Part 35 of 196The Ring programming language version 1.7 book - Part 35 of 196
The Ring programming language version 1.7 book - Part 35 of 196
 
Kotlin standard
Kotlin standardKotlin standard
Kotlin standard
 
Sneaking inside Kotlin features
Sneaking inside Kotlin featuresSneaking inside Kotlin features
Sneaking inside Kotlin features
 
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...
 
Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)
Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)
Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)
 
Closure, Higher-order function in Swift
Closure, Higher-order function in SwiftClosure, Higher-order function in Swift
Closure, Higher-order function in Swift
 
A Skeptics guide to functional style javascript
A Skeptics guide to functional style javascriptA Skeptics guide to functional style javascript
A Skeptics guide to functional style javascript
 
Kotlin
KotlinKotlin
Kotlin
 
Ciklum net sat12112011-alexander fomin-expressions and all, all, all
Ciklum net sat12112011-alexander fomin-expressions and all, all, allCiklum net sat12112011-alexander fomin-expressions and all, all, all
Ciklum net sat12112011-alexander fomin-expressions and all, all, all
 
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...
Analysis of Fatal Utah Avalanches with Python. From Scraping, Analysis, to In...
 
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...
How to Become a Tree Hugger: Random Forests and Predictive Modeling for Devel...
 
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
Elixir  -Tolerância a Falhas para Adultos - GDG CampinasElixir  -Tolerância a Falhas para Adultos - GDG Campinas
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
 
Python-Tuples
Python-TuplesPython-Tuples
Python-Tuples
 

En vedette

ธรรมะกฎแห่งกรรม
ธรรมะกฎแห่งกรรมธรรมะกฎแห่งกรรม
ธรรมะกฎแห่งกรรมnidkybynew
 
โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2nidkybynew
 
ธรรมะกฎแห่งกรรม
ธรรมะกฎแห่งกรรมธรรมะกฎแห่งกรรม
ธรรมะกฎแห่งกรรมnidkybynew
 
โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2nidkybynew
 
โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2nidkybynew
 
โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2nidkybynew
 

En vedette (7)

ธรรมะกฎแห่งกรรม
ธรรมะกฎแห่งกรรมธรรมะกฎแห่งกรรม
ธรรมะกฎแห่งกรรม
 
460 890-1-sm
460 890-1-sm460 890-1-sm
460 890-1-sm
 
โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2
 
ธรรมะกฎแห่งกรรม
ธรรมะกฎแห่งกรรมธรรมะกฎแห่งกรรม
ธรรมะกฎแห่งกรรม
 
โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2
 
โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2
 
โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2โยคะเพื่อสุขภาพ2
โยคะเพื่อสุขภาพ2
 

Similaire à Listing program

Similaire à Listing program (20)

Lampiran source code
Lampiran source codeLampiran source code
Lampiran source code
 
Vb file
Vb fileVb file
Vb file
 
Andres y keitleen
Andres y keitleenAndres y keitleen
Andres y keitleen
 
Stop watch and array
Stop watch and arrayStop watch and array
Stop watch and array
 
Colegio municipal
Colegio municipalColegio municipal
Colegio municipal
 
Yolygambas
YolygambasYolygambas
Yolygambas
 
Yolygambas
YolygambasYolygambas
Yolygambas
 
Yolygambas
YolygambasYolygambas
Yolygambas
 
Catatan rumus pb
Catatan rumus pbCatatan rumus pb
Catatan rumus pb
 
Vbreport program
Vbreport programVbreport program
Vbreport program
 
Calculadora
CalculadoraCalculadora
Calculadora
 
Practica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabarPractica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabar
 
ejemplos gambas
ejemplos gambasejemplos gambas
ejemplos gambas
 
Ejemplo En Gamabas
Ejemplo En GamabasEjemplo En Gamabas
Ejemplo En Gamabas
 
Sachin Foujdar , BCA Third Year
Sachin Foujdar , BCA Third YearSachin Foujdar , BCA Third Year
Sachin Foujdar , BCA Third Year
 
Calculadora
CalculadoraCalculadora
Calculadora
 
Calculadora
CalculadoraCalculadora
Calculadora
 
Corona sdk
Corona sdkCorona sdk
Corona sdk
 
Docimp
DocimpDocimp
Docimp
 
Cómo programar label
Cómo programar labelCómo programar label
Cómo programar label
 

Listing program

  • 1. LAMPIRAN A-1 LISTING PROGRAM 1. Login Option Explicit Dim rsUser As Recordset Private Sub cboUser_Click() txtPass.Locked = False txtPass.SetFocus End Sub Private Sub cmdCancel_Click() End End Sub Private Sub cmdOK_Click() On Error Resume Next Set 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 If End Sub Private Sub Form_Activate() txtPass = "" cboUser = "" cboUser.SetFocus End Sub Private Sub Form_Load() Koneksi Set rsUser = New ADODB.Recordset rsUser.Open "Select * from tUser order by UserId asc", CN, adOpenDynamic, adLockOptimistic Do Until rsUser.EOF = True cboUser.AddItem rsUser.Fields("UserId") rsUser.MoveNext Loop End Sub Private Sub txtPass_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdOk.Enabled = True cmdOk.SetFocus End If End Sub Private Sub cboUser_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtPass.Locked = False txtPass.SetFocus End If End Sub
  • 2. LAMPIRAN A-2 2. Menu Utama Private Sub cmdAbout_Click() frmAbout.Show End Sub Private Sub cmdQuit_Click() End End Sub Private Sub cmdReq_Click() MainForm.Show End Sub Private Sub cmdUtil_Click() frmMenuADM.Show End Sub Private Sub Form_Activate() Timer1.Enabled = True End Sub 3.Request Dim rsLagu As Recordset Dim KdLagu As String Dim IDRequest As Integer Private Sub cmdQuit_Click() If InTray = True Then Call TrayModule.DeleteIcon(MainForm) End If Unload Me Unload AddForm End Sub Private Sub cmdStart_Click() cmdStart.Enabled = False Call Start End Sub Sub 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
  • 3. LAMPIRAN A-3 lblNmFile.Caption = "" End If Set rsLagu = Nothing Else KdLagu = "" End If Set rsCari = Nothing Set rsCari = New ADODB.Recordset rsCari.Open "Update tDatarequest SET stPutar= '*' where idrequest=" & IDRequest & "", CN, 1, 2 Set rsCari = Nothing End Sub Private Sub Command1_Click() AddForm.Show End Sub Private Sub Command2_Click() On Error GoTo skip Dim Selected As Integer MusicName = Music.Text Selected = Music.ListIndex Music.RemoveItem (Selected) PathList.RemoveItem (Selected) Module1.SaveFile Play2action.Enabled = True Timer1.Enabled = False leftlabel.Caption = "0" Playaction.Enabled = True pauseaction.Enabled = False pausebutton.Enabled = False stopbutton.Enabled = False stopaction.Enabled = False Exit Sub End Sub Private Sub deleteaction_Click() On Error GoTo skip MusicName = Music.Text Music.RemoveItem (Music.ListIndex) WindowsMediaPlayer1.Controls.Stop playbutton.Enabled = True Playaction.Enabled = True Play2action.Enabled = True Exit Sub End 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 If End If End Sub
  • 4. 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 If End Sub Private Sub Music_Click() If Music.ListCount > 0 Then Module1.MusicClick End If End Sub Private Sub Music_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Module1.MusicClick ElseIf Button = 2 Then PopupMenu musicmenu End If End Sub Private Sub Music_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Music.ToolTipText = MusicName End Sub Private Sub NextAction_Click() Call TrayNext_Click End Sub Private Sub OrderAction_Click() Dim MusicName As String Dim MusicPath As String Dim i, j, k As Integer Dim Index1, Index2 As Integer Dim Letter1, Letter2 As String Dim OldCaption As String OldCaption = Me.Caption Me.Caption = "Ordering..."
  • 5. LAMPIRAN A-5 If Music.ListCount >= 2 Then i = Music.ListCount - 2 Do While i > -1 j = 1 Compare: Letter1 = UCase(Mid(Music.List(i), j, 1)) Letter2 = UCase(Mid(Music.List(i + 1), j, 1)) If Letter2 < Letter1 Then Switch: 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 If Cont: i = i - 1 Loop End If Me.Caption = OldCaption End Sub Private Sub Play2action_Click() Module1.Play End Sub Private Sub playbutton_Click() playbutton.Enabled = True Module1.Play End Sub Private Sub pausebutton_Click() Module1.Pause End Sub Private Sub playmenu_Click() If Music.ListCount > 0 Then NextAction.Enabled = True BackAction.Enabled = True End If End Sub
  • 6. LAMPIRAN A-6 Private Sub SendToTray_Click() If InTray = False Then Me.Hide Call TrayModule.AddIcon(MainForm, currentlyplaying) End If End Sub Private Sub ShowAction_Click() If InTray = True Then MainForm.Show Call TrayModule.DeleteIcon(MainForm) End If End Sub Private Sub ShuffleAction_Click() Dim Songs As Integer Dim i As Integer Dim NewPos As Integer Dim Name1 As String Dim Name2 As String Dim Path1, Path2 As String Dim Taken() As Integer Randomize Songs = Music.ListCount ReDim Taken(Songs) As Integer i = 0 Do While i < Songs Taken(i) = 0 i = i + 1 Loop i = 0 Do While i < Songs If Taken(i) = 0 Then NewPos = (Rnd * (Songs - 2)) + 1 Taken(i) = 1 Taken(NewPos) = 1 Name1 = Music.List(i) Path1 = PathList.List(i) Name2 = Music.List(NewPos) Path2 = PathList.List(NewPos) Music.List(i) = Name2 PathList.List(i) = Path2 Music.List(NewPos) = Name1 PathList.List(NewPos) = Path1 End If i = i + 1 Loop Music.Refresh End Sub Private Sub Slider1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 39 Or KeyCode = 37 Then On Error GoTo skip moving = True End If Exit Sub skip: End Sub
  • 7. LAMPIRAN A-7 Private Sub Slider1_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode = 39 Or KeyCode = 37 Then On Error GoTo skip WindowsMediaPlayer1.Controls.currentPosition = Slider1.Value leftlabel.Caption = Slider1.Value moving = False End If Exit Sub skip: End Sub Private Sub Slider1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) On Error GoTo skip If Button = 1 Then moving = True PButton = 1 Else PButton = 2 End If Exit Sub skip: End Sub Private Sub Slider1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) On Error GoTo skip If PButton = 1 Then WindowsMediaPlayer1.Controls.currentPosition = Slider1.Value leftlabel.Caption = Slider1.Value moving = False End If Exit Sub skip: End Sub Private Sub stopbutton_Click() Module1.StopSong playbutton.Enabled = True End Sub Private Sub Cover_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 2 Then PopupMenu playmenu End If End Sub Sub Segar() Set rsCari = New ADODB.Recordset rsCari.Open "Select * from tDataRequest order by IdRequest asc", CN, 1, 2 Adodc1.Refresh grid.Refresh grid.ColWidth(0) = 0 grid.ColWidth(1) = 1000 grid.ColWidth(2) = 1000 grid.ColWidth(3) = 1200 grid.ColWidth(4) = 1200 grid.TextMatrix(0, 0) = "" grid.TextMatrix(0, 1) = "Id Req"
  • 8. LAMPIRAN A-8 grid.TextMatrix(0, 2) = "Id SMS" grid.TextMatrix(0, 3) = "Tgl Req" grid.TextMatrix(0, 4) = "Kode Lagu" Set rsCari = Nothing End Sub Private Sub Form_Activate() Call Segar End Sub Private Sub Form_Load() Koneksi Dim FR As Integer Dim FullName As String Dim i As Integer Dim DirName As String FR = FreeFile Music.Clear PathList.Clear VolumeControl.Value = WindowsMediaPlayer1.Settings.Volume leftlabel.Caption = "-1" moving = False autoloading = 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 #FR exitloop: autoloading = False currentlyplaying = "" Call OrderAction_Click End If End Sub Private Sub Form_Unload(Cancel As Integer) If InTray = True Then Call TrayModule.DeleteIcon(MainForm) End If Unload Me Unload AddForm End Sub Private Sub minaction_Click() MainForm.WindowState = 1 Unload AddForm End Sub Private Sub pauseaction_Click() Module1.Pause End Sub
  • 9. LAMPIRAN A-9 Private Sub playaction_Click() Module1.Play End Sub Private Sub quitaction_Click() Unload Me Unload AddForm End Sub Private Sub Stopaction_Click() Module1.StopSong End Sub Private Sub Timer1_Timer() leftlabel.Caption = leftlabel.Caption + 1 If leftlabel.Caption >= WindowsMediaPlayer1.currentMedia.duration And WindowsMediaPlayer1.currentMedia.duration > 0 Then On Error GoTo restart Music.ListIndex = Music.ListIndex + 1 leftlabel.Caption = "0" End If Timer1.Enabled = False Timer1.Enabled = True If moving = False Then Timer2.Enabled = True Slider1.Value = WindowsMediaPlayer1.Controls.currentPosition End If Module1.ConvertMinuets (Slider1.Value) Dim temp As String temp = CTime Module1.ConvertMinuets (WindowsMediaPlayer1.currentMedia.duration) Slider1.ToolTipText = temp & "/" & CTime Exit Sub restart: Music.ListIndex = 0 leftlabel.Caption = "0" End Sub Private Sub Timer2_Timer() On Error GoTo atempt currentduration = WindowsMediaPlayer1.currentMedia.duration Slider1.Max = currentduration Timer2.Enabled = False Exit Sub atempt: currentduration = WindowsMediaPlayer1.currentMedia.duration If currentduration > 0 Then Slider1.Max = currentduration Timer2.Enabled = False End Sub Private Sub TrayBack_Click() On Error GoTo 1 If Music.ListIndex > 0 Then Music.ListIndex = Music.ListIndex - 1 Else GoTo 1 End If Exit Sub 1: Music.ListIndex = Music.ListCount - 1 End Sub
  • 10. LAMPIRAN A-10 Private Sub TrayExit_Click() Unload Me Unload AddForm End Sub Private Sub TrayMenu_Click() If playbutton.Enabled = True Then TrayPlay.Enabled = True Else TrayPlay.Enabled = False End If If pausebutton.Enabled = True Then TrayPause.Enabled = True Else TrayPause.Enabled = False End If If stopbutton.Enabled = True Then TrayStop.Enabled = True Else TrayStop.Enabled = False End If If Music.ListCount > 0 Then TrayNext.Enabled = True TrayBack.Enabled = True Else TrayNext.Enabled = False TrayBack.Enabled = False End If End Sub Private Sub TrayNext_Click() On Error GoTo 1 Music.ListIndex = Music.ListIndex + 1 Exit Sub 1: Music.ListIndex = 0 End Sub Private Sub TrayPause_Click() Module1.Pause End Sub Private Sub TrayPlay_Click() Module1.Play End Sub Private Sub TrayStop_Click() Module1.StopSong End Sub Private Sub Unload2action_Click() On Error GoTo skip Dim i For i = 0 To Music.ListCount - 1 If Music.Selected(i) Then Music.RemoveItem (i) WindowsMediaPlayer1.Controls.Stop Timer1.Enabled = False
  • 11. LAMPIRAN A-11 playbutton.Enabled = True Playaction.Enabled = True Play2action.Enabled = False leftlabel.Caption = "0" stopbutton.Enabled = False stopaction.Enabled = False pausebutton.Enabled = False pauseaction.Enabled = False End If Next i Exit Sub skip: End Sub Private Sub unloadaction_Click() Music.Clear Timer1.Enabled = False WindowsMediaPlayer1.Controls.Stop leftlabel.Caption = "0" playbutton.Enabled = False Playaction.Enabled = False Play2action.Enabled = False stopbutton.Enabled = False stopaction.Enabled = False pausebutton.Enabled = False pauseaction.Enabled = False Me.Caption = "J34 Media Player" End Sub Private Sub VolumeControl_Change() WindowsMediaPlayer1.Settings.Volume = VolumeControl.Value End Sub Private Sub VolumeControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) VolumeControl.ToolTipText = VolumeControl.Value End Sub Private Sub WindowsMediaPlayer1_MouseDown(ByVal nButton As Integer, ByVal nShiftState As Integer, ByVal fX As Long, ByVal fY As Long) If nButton = 2 Then PopupMenu playmenu End If End Sub 4. Menu Utility Private Sub cmdLagu_Click() frmLagu.Show End Sub Private Sub cmdUser_Click() frmUser.Show End Sub Private Sub cmdKeluar_Click() Me.Hide Unload Me frmUtama.Show End Sub
  • 12. LAMPIRAN A-12 Private Sub Form_Unload(Cancel As Integer) Me.Hide Unload Me frmUtama.Show End Sub 5. Data Lagu Option Explicit Dim rsKata As Recordset Sub Segar() Set rsCari = New ADODB.Recordset rsCari.Open "Select * from tLagu order by KdLagu asc", CN, 1, 2 Adodc1.Refresh grid.Refresh grid.ColWidth(0) = 0 grid.ColWidth(1) = 1000 grid.ColWidth(2) = 4000 grid.ColWidth(3) = 7000 grid.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() mati bersih tambah = False Cari = False ubah = False cmdTambah.Enabled = True cmdCari.Enabled = True cmdRubah.Visible = True cmdRubah.Enabled = False cmdUpdate.Visible = False cmdHapus.Enabled = False cmdBatal.Enabled = True cmdTambah.Visible = True cmdTambah.Enabled = True cmdSave.Visible = False cmdTambah.SetFocus End Sub Private Sub cmdBrowse_Click() On Error Resume Next cmdBrowse.Enabled = False With CommonDialog1 .FileName = "*.mp3" .Filter = "mp3" .DialogTitle = "Pilih File Lagu" .ShowOpen txtNama = .FileTitle txtNmFile.Text = .FileName 'Left(.FileTitle, Len(.FileTitle) - 4) End With If tambah = True Then cmdSave.Visible = True cmdTambah.Visible = False End If End Sub
  • 13. LAMPIRAN A-13 Private Sub cmdCari_Click() Cari = True tambah = False ubah = False cmdTambah.Enabled = False cmdCari.Enabled = False txtKode.Locked = False txtKode.SetFocus End 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.SetFocus End Sub Private Sub cmdKeluar_Click() Unload Me End Sub Private Sub cmdRubah_Click() ubah = True Cari = False tambah = False cmdBrowse.Enabled = True cmdRubah.Visible = False cmdUpdate.Visible = True cmdHapus.Enabled = False txtNama.Locked = False txtNama.SetFocus End Sub Private Sub cmdSave_Click() cmdSave.Visible = False cmdTambah.Visible = True Call Save Call bersih Call mati Call Segar cmdTambah.SetFocus End Sub Private Sub cmdTambah_Click() tambah = True Cari = False ubah = False cmdBrowse.Enabled = True cmdTambah.Enabled = False cmdSave.Visible = True
  • 14. LAMPIRAN A-14 cmdCari.Enabled = False txtKode.Locked = False txtKode.SetFocus End 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, adLockOptimistic ubah = False mati bersih Segar MsgBox "Data Lagu sudah di Update" cmdUpdate.Visible = False cmdHapus.Enabled = False cmdRubah.Visible = True cmdRubah.Enabled = False cmdCari.Enabled = True cmdTambah.Visible = True cmdTambah.Enabled = True cmdTambah.SetFocus End Sub Sub 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.Update End Sub Private Sub Form_Activate() mati bersih grid.ColWidth(0) = 0 grid.ColWidth(1) = 1000 grid.ColWidth(2) = 4000 grid.ColWidth(3) = 7000 grid.TextMatrix(0, 0) = "" grid.TextMatrix(0, 1) = "Kode" grid.TextMatrix(0, 2) = "Nama Lagu" grid.TextMatrix(0, 3) = "Nama File" cmdCari.Enabled = True cmdTambah.Enabled = True cmdRubah.Enabled = False cmdUpdate.Visible = False cmdSave.Visible = False cmdHapus.Enabled = False cmdBatal.Enabled = True cmdBrowse.Enabled = False cmdTambah.SetFocus End Sub Private Sub Form_Load() Koneksi End Sub
  • 15. LAMPIRAN A-15 Sub mati() txtKode.Locked = True txtNama.Locked = True txtNmFile.Locked = True End Sub Sub 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 If End 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
  • 16. LAMPIRAN A-16 cmdRubah.Enabled = True cmdHapus.Enabled = True cmdRubah.SetFocus Else MsgBox "Data tidak ada" txtKode.Text = "" txtKode.SetFocus End If End If End If End Sub Private Sub txtKode_Change() If Len(txtKode) < 5 Then Exit Sub Else 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 If End If End Sub Private Sub txtNama_Change() If ubah = True Then cmdRubah.Visible = False cmdHapus.Enabled = False cmdUpdate.Visible = True End If End Sub Private Sub txtNama_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdBrowse.Enabled = True cmdBrowse.SetFocus End If End Sub
  • 17. LAMPIRAN A-17 6. Data User Option Explicit Dim rsPasswd As Recordset Private Sub cmdBatal_Click() txtUserID.Text = "" txtPasswd.Text = "" ubah = False tambah = False Cari = False cmdRubah.Enabled = False cmdHapus.Enabled = False cmdCari.Enabled = True cmdTambah.Enabled = True cmdTambah.SetFocus End Sub Private Sub cmdCari_Click() Cari = True cmdTambah.Enabled = False cmdCari.Enabled = False txtUserID.Locked = False txtUserID.SetFocus End 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.SetFocus End Sub Private Sub cmdKeluar_Click() Unload Me End Sub Private Sub cmdRubah_Click() ubah = True cmdRubah.Visible = False cmdHapus.Enabled = False cmdUpdate.Visible = True txtPasswd.Locked = False txtPasswd.SetFocus End Sub Private Sub cmdSave_Click() If tambah = True Then Call Save End If End Sub
  • 18. LAMPIRAN A-18 Private Sub cmdTambah_Click() tambah = True cmdTambah.Visible = False cmdSave.Visible = True cmdCari.Enabled = False cmdCari.Enabled = False txtUserID.Locked = False txtUserID.SetFocus End 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.SetFocus End If End Sub Private Sub Form_Activate() txtUserID.Locked = True txtPasswd.Text = "" txtUserID.Text = "" ubah = False tambah = False Cari = False cmdRubah.Visible = True cmdRubah.Enabled = False cmdUpdate.Visible = False cmdHapus.Enabled = False cmdCari.Enabled = True cmdTambah.Visible = True cmdSave.Visible = False cmdTambah.Enabled = True cmdTambah.SetFocus End Sub Sub mati() txtUserID.Locked = True txtPasswd.Locked = True End Sub Sub bersih() txtUserID.Text = "" txtPasswd.Text = "" End Sub
  • 19. LAMPIRAN A-19 Private Sub Form_Load() Koneksi End 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 If End If End Sub Sub 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
  • 20. 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 If End If End Sub 7.About Private Sub cmdKeluar_Click() Unload frmAbout End Sub 8. Module-1(modPlayer) Option Explicit Private Const BIF_STATUSTEXT = &H4& Private Const BIF_RETURNONLYFSDIRS = 1 Private Const BIF_DONTGOBELOWDOMAIN = 2 Private Const MAX_PATH = 260 Private Const WM_USER = &H400 Private Const BFFM_INITIALIZED = 1 Private Const BFFM_SELCHANGED = 2 Private 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 Long Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
  • 21. 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 Long End 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 If End 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
  • 22. LAMPIRAN A-22 BrowseCallbackProc = 0 End Function Private Function GetAddressofFunction(add As Long) As Long GetAddressofFunction = add End Function 9. Module-2 (ModRequest) Option Explicit Global CN As Connection Public tambah As Boolean Public Cari As Boolean Public ubah As Boolean Public X As String Public rsSimpan As Recordset Public rsSimpan1 As Recordset Public rsCari As Recordset Public rsUbah As Recordset Public rsHapus As Recordset Public rsStatus As Recordset Public rsUpdate As Recordset Public rsSegar As Recordset Global Const SND_ASYNC = &H1, SND_NOSTOP = &H10 Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Public 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 Long Public Sub Koneksi() Set CN = New ADODB.Connection CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "dbSMSRequest.mdb;Persist Security Info=False" CN.Open End Sub 10. Module-3 (Module1) Option Explicit Public location As String Public MusicName As String Public moving As Boolean Public currentduration As Integer Public autoloading As Boolean Public currentlyplaying As String Public PButton As Single Public CTime As String Public Activated As Boolean
  • 23. LAMPIRAN A-23 Public Sub SaveFile() Dim FR As Integer Dim Line As String Dim i As Integer Dim Max As Integer FR = FreeFile i = 0 Max = MainForm.Music.ListCount Open App.Path & "Uploaded Music.J34" For Output As #FR Do While i < Max Print #FR, MainForm.PathList.List(i) i = i + 1 Loop Close #FR End Sub Public Function ReadFile() As String On Error GoTo BlankFile Dim FR As Integer Dim FileContents As String Dim FileLine FR = FreeFile Do While Not EOF(FR) Line Input #FR, FileLine FileContents = FileContents & vbNewLine & FileLine Loop Close #FR ReadFile = FileContents Exit Function BlankFile: ReadFile = "" End Function Public Sub ConvertMinuets(ByVal Sec As Integer) If Sec Mod 60 = 0 Then CTime = Sec 60 Else CTime = Sec 60 & " " & Sec Mod 60 End If End Sub Public Sub Play() MainForm.WindowsMediaPlayer1.Controls.Play Dim mlength As Integer Dim mstring As String 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 If End If If (currentlyplaying = "") = False Then MusicName = currentlyplaying MainForm.Caption = MusicName If InTray = False Then MainForm.pausebutton.SetFocus End Sub
  • 24. LAMPIRAN A-24 Public Sub Pause() MainForm.WindowsMediaPlayer1.Controls.Pause End Sub Public Sub StopSong() MainForm.WindowsMediaPlayer1.Controls.Stop End Sub Public Sub MusicClick() Dim mlength As Integer Dim mstring As String MusicName = MainForm.Music.Text MainForm.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 If End If MainForm.Caption = MusicName MainForm.WindowsMediaPlayer1.Controls.Play currentduration = MainForm.WindowsMediaPlayer1.currentMedia.duration MainForm.Timer1.Enabled = False MainForm.Timer1.Enabled = True MainForm.leftlabel.Caption = "0" MainForm.playbutton.Enabled = False MainForm.pausebutton.Enabled = True MainForm.stopbutton.Enabled = True currentlyplaying = MusicName If InTray = True Then Call ModifyIcon(MainForm, currentlyplaying) End If End Sub 11. Module-4 (TrayModule) Public Declare Function Shell_NotifyIconA Lib "shell32.dll" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Integer Const NIM_ADD = &H0 Const NIM_MODIFY = &H1 Const NIM_DELETE = &H2 Const NIF_MESSAGE = &H1 Const NIF_ICON = &H2 Const NIF_TIP = &H4 Public Const WM_LBUTTONDOWN = &H201 Public Const WM_RBUTTONDOWN = &H204 Public Const WM_LBUTTONDBLCLK = &H203
  • 25. 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 * 64 End Type Public 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 = vbNull End With Call Shell_NotifyIconA(NIM_ADD, AddIconData) InTray = True End 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 = vbNull End With Call Shell_NotifyIconA(NIM_MODIFY, AddIconData) InTray = True End 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 = vbNull End With Call Shell_NotifyIconA(NIM_DELETE, AddIconData) InTray = False End Sub