VB 打开TEXT1中所指的文件 非常急~~~~~

我现在想做一个倒计时程序,如果倒数到0的话打开 D:\VB\music\great.mp3
怎么办,请填写我的代码:
Private Sub Text1_Change()
If Text1.Text = "0" Then
---------------------------填什么
End If
End Sub
超级急啊 越早加越多分!!!!!
不是 zcxv1221 所说的 text中的路径随时改变的!

代码如下:

Option Explicit

Private 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

Private Sub Command1_Click()
Dim str As String
str = Trim(Text1.Text)
ShellExecute 0, "Open", str, "", "", 1
End Sub

这个是传说中的打开任意类型文件的代码了,哈哈,楼主注意提前是你的电脑中首先要支持你打开的文件类型,比如说RMVB文件,你的电脑要有播放它的程序,上面的代码会自动选择默认程序来打开它.

缺点是会显示打开文件的程序,优点就是几乎全能的.如果你确定只是打开声音文件请看现下面的类:

Media.cls
----------------
Option Explicit

Private sAlias As String
Private sFilename As String
Private nLength As Single
Private nPosition As Single
Private sStatus As String
Private bWait As Boolean
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

Public Sub mmOpen(ByVal sTheFile As String)
Dim nReturn As Long
Dim sType As String
If sAlias <> "" Then
mmClose
End If
Select Case UCase$(Right$(sTheFile, 3))
Case "WAV"
sType = "Waveaudio"
Case "AVI"
sType = "AviVideo"
Case "MID"
sType = "Sequencer"
Case Else
Exit Sub
End Select
sAlias = Right$(sTheFile, 3) & Minute(Now)
If InStr(sTheFile, " ") Then sTheFile = Chr(34) & sTheFile & Chr(34)
nReturn = mciSendString("Open " & sTheFile & " ALIAS " & sAlias _
& " TYPE " & sType & " wait", "", 0, 0)
End Sub

Public Sub mmClose()
Dim nReturn As Long
If sAlias = "" Then Exit Sub
nReturn = mciSendString("Close " & sAlias, "", 0, 0)
sAlias = ""
sFilename = ""
End Sub

Public Sub mmPause()
Dim nReturn As Long
If sAlias = "" Then Exit Sub
nReturn = mciSendString("Pause " & sAlias, "", 0, 0)
End Sub

Public Sub mmPlay()
Dim nReturn As Long
If sAlias = "" Then Exit Sub
If bWait Then
nReturn = mciSendString("Play " & sAlias & " wait", "", 0, 0)
Else
nReturn = mciSendString("Play " & sAlias, "", 0, 0)
End If
End Sub

Public Sub mmStop()
Dim nReturn As Long
If sAlias = "" Then Exit Sub
nReturn = mciSendString("Stop " & sAlias, "", 0, 0)
End Sub

Public Sub mmSeek(ByVal nPosition As Single)
Dim nReturn As Long
nReturn = mciSendString("Seek " & sAlias & " to " & nPosition, "", 0, 0)
End Sub

Property Get Filename() As String
Filename = sFilename
End Property

Property Let Filename(ByVal sTheFile As String)
mmOpen sTheFile
End Property

Property Get Wait() As Boolean
Wait = bWait
End Property

Property Let Wait(bWaitValue As Boolean)
bWait = bWaitValue
End Property

Property Get Length() As Single
Dim nReturn As Long, nLength As Integer
Dim sLength As String * 255
If sAlias = "" Then
Length = 0
Exit Property
End If

nReturn = mciSendString("Status " & sAlias & " length", sLength, 255, 0)
nLength = InStr(sLength, Chr$(0))
Length = Val(Left$(sLength, nLength - 1))
End Property

Property Let Position(ByVal nPosition As Single)
mmSeek nPosition
End Property

Property Get Position() As Single
Dim nReturn As Integer, nLength As Integer
Dim sPosition As String * 255
If sAlias = "" Then Exit Property
nReturn = mciSendString("Status " & sAlias & " position", sPosition, 255, 0)
nLength = InStr(sPosition, Chr$(0))
Position = Val(Left$(sPosition, nLength - 1))
End Property

Property Get Status() As String
Dim nReturn As Integer, nLength As Integer
Dim sStatus As String * 255
If sAlias = "" Then Exit Property
nReturn = mciSendString("Status " & sAlias & " mode", sStatus, 255, 0)
nLength = InStr(sStatus, Chr$(0))
Status = Left$(sStatus, nLength - 1)
End Property

这个类支持各种声音文件,使用方法是:
1.mmopen("声音文件名")
2.mmplay()播放
3.mmpause()暂停
4.mmclose()关闭
5.mmstop()停止
其它的功能你基本就用不上了.
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-03-05
这要看你是用什么方式来打开这个文件了,比如用WMP来播放这个MP3文件:

Private Sub Text1_Change()
If Text1.Text = "0" Then
WindowsMediaPlayer1.URL = "D:\VB\music\great.mp3"
End If
End Sub
第2个回答  2010-03-04
先定义m=10

然后在timer里加入

m=m-1
text1=m
if m=0 then
'打开D:\VB\music\great.mp3

end if

关键是事件放在timer里,
第3个回答  2010-03-04
如果打开MP3文件,你可以用API函数PlaySound来实现。
Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

其中lpszName="D:\VB\music\great.mp3"
后面两参数可不选。
第4个回答  2010-03-04
Shell "rundll32.exe url.dll,FileProtocolHandler " & Text1
相似回答