View Single Post
Old May 31st, 2005, 1:43 PM   #2
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
This should do it:
Private Sub Form_Click()
VB.Clipboard.SetText Round(MMControl1.Position / MMControl1.Length * 100) & " % elapsed"
End Sub

Private Sub Form_Load()
MMControl1.FileName = "C:\Windows\Media\Tada.wav"
MMControl1.Command = "Open"
MMControl1.TimeFormat = mciFormatFrames
'Sets the time format to frames
End Sub
As we're calculating the % elapsed, the time format is arbitrary, so frames (meaning individual moments of sound, like frames in a video) are used. If you want to display the actual HH:MMS, check http://msdn.microsoft.com/library/de...imefmt_mci.asp for information on decoding the various time formats.
However, if you're running XP there is a bug with the clipboard object in VB IDE (it doesn't work!), but not when compiled: try doing debug.print to see the results.
Rory is offline   Reply With Quote