为什么要用控件?直接用api函数mcisendstring不好吗? Private 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 Dim Alias As String Private Sub Form_Load() 'KPD-Team 1998 'URL: http://www.allapi.net/ 'E-Mail: [email protected] Const PlayTime = 10 'Set the common dialog box' title CDBox.DialogTitle = "Choose your midi-file" 'Set the filter CDBox.Filter = "Midi-files (*.mid)|*.mid" 'Show the 'Open File'-dialog CDBox.ShowOpen 'Extract an alias from the file Alias = Left$(CDBox.FileTitle, Len(CDBox.FileTitle) - 4) 'play midi R% = mciSendString("OPEN " + CDBox.filename + " TYPE SEQUENCER ALIAS " + Alias, 0&, 0, 0) R% = mciSendString("PLAY " + Alias + " FROM 0", 0&, 0, 0) R% = mciSendString("CLOSE ANIMATION", 0&, 0, 0) 'play midi for 10 secs t = Timer Do: DoEvents: Loop Until Timer > t + PlayTime 'stop midi and close it R% = mciSendString("OPEN " + CDBox.filename + " TYPE SEQUENCER ALIAS " + Alias, 0&, 0, 0) R% = mciSendString&("STOP " + Alias, 0&, 0, 0) R% = mciSendString&("CLOSE ANIMATION", 0&, 0, 0) End Sub
Private 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
Dim Alias As String
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Const PlayTime = 10
'Set the common dialog box' title
CDBox.DialogTitle = "Choose your midi-file"
'Set the filter
CDBox.Filter = "Midi-files (*.mid)|*.mid"
'Show the 'Open File'-dialog
CDBox.ShowOpen
'Extract an alias from the file
Alias = Left$(CDBox.FileTitle, Len(CDBox.FileTitle) - 4) 'play midi
R% = mciSendString("OPEN " + CDBox.filename + " TYPE SEQUENCER ALIAS " + Alias, 0&, 0, 0)
R% = mciSendString("PLAY " + Alias + " FROM 0", 0&, 0, 0)
R% = mciSendString("CLOSE ANIMATION", 0&, 0, 0) 'play midi for 10 secs
t = Timer
Do: DoEvents: Loop Until Timer > t + PlayTime 'stop midi and close it
R% = mciSendString("OPEN " + CDBox.filename + " TYPE SEQUENCER ALIAS " + Alias, 0&, 0, 0)
R% = mciSendString&("STOP " + Alias, 0&, 0, 0)
R% = mciSendString&("CLOSE ANIMATION", 0&, 0, 0)
End Sub
你的代码不能正确运行!!!