可以播放MP3,WAV,MID,WMA...
大家可以给些意见...
可以设置6个时间点...[em48]
FORM1代码: '------------------------------------------------------------ '------------------------------------------------------------ '------------------------------------------------------------ '------------------------------------------------------------ '------------------------------------------------------------ '控件的XP风格,对程序只有美化作用.完全可以不要 ^_^ Private Declare Sub InitCommonControls Lib "comctl32.dll" () Private Sub Form_Initialize() InitCommonControls End Sub '------------------------------------------------------------ '------------------------------------------------------------ '------------------------------------------------------------ Private Sub Combo1_Click() h.Text = "" m.Text = "" h.Enabled = True m.Enabled = True Label7.Caption = "" End Sub
Private Sub Command4_Click() Dim OpenFile As OPENFILENAME Dim lReturn As Long Dim sFilter As String OpenFile.lStructSize = Len(OpenFile) OpenFile.hwndOwner = Form1.hwnd OpenFile.hInstance = App.hInstance sFilter = "音频格式" & Chr$(0) & "*.mp3;*.wav;*.mid;*.midi;*.wma" & Chr$(0) OpenFile.lpstrFilter = sFilter OpenFile.nFilterIndex = 1 OpenFile.lpstrFile = String(257, 0) OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1 OpenFile.lpstrFileTitle = OpenFile.lpstrFile OpenFile.nMaxFileTitle = OpenFile.nMaxFile OpenFile.lpstrTitle = "选择音乐文件" OpenFile.flags = cdlOFNNoChangeDir And cdlOFNPathMustExist lReturn = GetOpenFileName(OpenFile) On Error GoTo Err sound.Text = OpenFile.lpstrFile mfn = GetShortFileName(OpenFile.lpstrFileTitle) Text1.Text = mfn Err: Text1.Text = mfn End Sub
Private Sub Command5_Click() Label6.Visible = False Command5.Visible = False End Sub
Private Sub Command1_Click() h.Enabled = False m.Enabled = False Label7.Caption = "闹铃" & vbCrLf & vbCrLf & "设置" & vbCrLf & vbCrLf & "成功" If combo1.ListIndex = 0 Then ring1.Caption = h.Text & ":" & m.Text & ":" & "00" sound1.Text = Text1.Text End If If combo1.ListIndex = 1 Then ring2.Caption = h.Text & ":" & m.Text & ":" & "00" sound2.Text = Text1.Text End If If combo1.ListIndex = 2 Then ring3.Caption = h.Text & ":" & m.Text & ":" & "00" sound3.Text = Text1.Text End If If combo1.ListIndex = 3 Then ring4.Caption = h.Text & ":" & m.Text & ":" & "00" sound4.Text = Text1.Text End If If combo1.ListIndex = 4 Then ring5.Caption = h.Text & ":" & m.Text & ":" & "00" sound5.Text = Text1.Text End If If combo1.ListIndex = 5 Then ring6.Caption = h.Text & ":" & m.Text & ":" & "00" sound6.Text = Text1.Text End If End Sub
Private Sub Command2_Click() h.Text = "" m.Text = "" h.Enabled = True m.Enabled = True Label7.Caption = "" End Sub
Private Sub Command3_Click() End End Sub
Private Sub Form_Load() Label2.Caption = Format(Now, "hh:mm:ss") combo1.ListIndex = 0 End Sub
Private Sub Timer1_Timer() Label2.Caption = Format(Now, "hh:mm:ss")
If Label2.Caption = ring1.Caption Then t% = mciSendString("play " + sound1.Text + " from " + Str(0), 0&, 0, 0) End If If Label2.Caption = ring2.Caption Then t% = mciSendString("play " + sound2.Text + " from " + Str(0), 0&, 0, 0) End If If Label2.Caption = ring3.Caption Then t% = mciSendString("play " + sound3.Text + " from " + Str(0), 0&, 0, 0) End If If Label2.Caption = ring4.Caption Then t% = mciSendString("play " + sound4.Text + " from " + Str(0), 0&, 0, 0) End If If Label2.Caption = ring5.Caption Then t% = mciSendString("play " + sound5.Text + " from " + Str(0), 0&, 0, 0) End If If Label2.Caption = ring6.Caption Then t% = mciSendString("play " + sound6.Text + " from " + Str(0), 0&, 0, 0) End If End Sub
dlg(CODE): Option Explicit Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _ "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As String End Type '-------------------------------------------------------- otherModule(CODE): '------------------------------------------------------------------ '------------------------------------------------------------------ '--------------------------XP控件风格------------------------------ Declare Sub InitCommonControls Lib "comctl32.dll" () '------------------------------------ '------------------------------------ '添加模块,做以下声明: '------------------------------------ '------------------------------------ Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrRetumString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'------------------------------------ '------------------------------------ '====================================取長文件名的短文件名======================================== Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long Public Function GetShortFileName(ByVal FileName As String) As String Dim rc As Long Dim ShortPath As String Const PATH_LEN& = 164 ShortPath = String$(PATH_LEN + 1, 0) rc = GetShortPathName(FileName, ShortPath, PATH_LEN) GetShortFileName = Left$(ShortPath, rc) End Function 'mfn = GetShortFileName(CommonDialog1.FileName) '取短文件名