我在网上下载了一个vb小程序,看不太懂,因为初学vb,能不能给我解释一下,在线等
很着急,谢谢了
Option Explicit
Dim trackLength(20) As String
Dim min As Integer
Dim track1 As Integer
Dim sec As Integer
Private Sub cmdClose_Click()
mciSendString "stop MyMedia", vbNullString, 0, 0
mciSendString "close MyMedia", vbNullString, 0, 0
End Sub
Private Sub cmdDoorClose_Click()
mciSendString "set MyMedia door closed", vbNullString, 0, 0
End Sub
Private Sub cmdEject_Click()
mciSendString "set MyMedia door open", vbNullString, 0, 0
End Sub
Private Sub cmdNext_Click()
Dim S As String, Tracks As Integer, CurTrack As Integer
S = String(256, Chr(0))
mciSendString "status MyMedia number of tracks", S, Len(S), 0
Tracks = Val(S)
mciSendString "status MyMedia current track", S, Len(S), 0
CurTrack = Val(S)
If CurTrack < Tracks Then
mciSendString "status MyMedia position track " & CurTrack + 1, S, Len(S), 0
mciSendString "play MyMedia from " & Left(S, 8), vbNullString, 0, 0
End If
End Sub
Private Sub cmdOpen_Click()
Dim ret As Long, S As String
Dim i As Integer
mciSendString "close MyMedia", vbNullString, 0, 0
ret = mciSendString("open cdaudio alias MyMedia", vbNullString, 0, 0)
If ret = 0 Then
Dim Length As String, Tracks As Integer
S = String(256, Chr(0))
mciSendString "status MyMedia length", S, Len(S), 0
Length = Left(S, 8)
mciSendString "status MyMedia number of tracks", S, Len(S), 0
Tracks = Val(S)
For i = 1 To Tracks
List1.AddItem "第 " & i & " 首CD"
Next i
txtLength.Text = "[" & Tracks & "] " & Length
Else
S = String(256, Chr(0))
mciGetErrorString ret, S, Len(S)
MsgBox Left(S, InStr(S, Chr(0)) - 1)
End If
End Sub
Private Sub cmdPause_Click()
mciSendString "pause MyMedia", vbNullString, 0, 0
End Sub
Private Sub cmdPlay_Click()
mciSendString "play MyMedia", vbNullString, 0, 0
End Sub
Private Sub cmdPrev_Click()
Dim S As String, CurTrack As Integer
S = String(256, Chr(0))
mciSendString "status MyMedia current track", S, Len(S), 0
CurTrack = Val(S)
If CurTrack > 1 Then
mciSendString "status MyMedia position track " & CurTrack - 1, S, Len(S), 0
mciSendString "play MyMedia from " & Left(S, 8), vbNullString, 0, 0
End If
End Sub
Private Sub cmdReset_Click()
mciSendString "pause MyMedia", vbNullString, 0, 0
mciSendString "seek MyMedia to start", vbNullString, 0, 0
End Sub
Private Sub cmdVolume_Click()
Shell "Sndvol32.exe", vbNormalFocus
End Sub
Private Sub Form_Load()
Dim S As String
Dim i As Integer
S = String(256, Chr(0))
mciSendString "status cdaudio number of tracks", S, Len(S), 0
If Val(S) <> 0 Then cmdOpen_Click
mciSendString "play MyMedia", vbNullString, 0, 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
cmdClose_Click
End Sub
Private Sub List1_DblClick()
Dim S As String, k As Integer
S = String(256, Chr(0))
k = List1.ListIndex + 1
mciSendString "status MyMedia position track " & k, S, Len(S), 0
mciSendString "play MyMedia from " & Left(S, 8), vbNullString, 0, 0
End Sub
Private Sub Timer1_Timer()
Dim S As String, ret As Long, pos As String, track As Integer
S = String(256, 0)
mciSendString "status MyMedia position", S, Len(S), 0
pos = Left(S, 8)
mciSendString "status MyMedia current track", S, Len(S), 0
track = Val(S)
txtCurrent = "[" & track & "] " & pos
End Sub
Private Sub Timer2_Timer()
If List1.ListCount = 0 Then
cmdOpen_Click
End If
End Sub