Build an MP3 Player

Wrapping Up

As our last step, we need to add a procedure that clears the tag information from the textboxes, and code to fill the GenresTypes array. Listing F contains both procedures. To save space, we shortened the full list of genre types. For an expanded list, check out this month's download file.

Listing F: Remaining code

Private Sub EraseTXTBoxes()
lblMsg.Caption = ""
txtTitle = ""
txtArtist = ""
txtAlbum = ""
txtYear = ""
txtComment = ""
txtGenreCode = ""
Combo1.ListIndex = -1
End Sub
Private Sub Form_Load()
Dim x As Integer
Dim iLower As Integer 
Dim iUpper As Integer

Drive1.Drive = "C:" 
Dir1.Path = "C:"

GenresTypes = Array("Blues", "Classic Rock", "Country", _
	"Dance", "Disco", "Funk", "Grunge", "Hip -Hop", _
	"Jazz", "Metal", "New Age", "Oldies", "Other", _
	"Pop", "R&b", "Rap", "Reggae", "Rock", "Techno", _
	"Industrial", "Alternative", "Ska", "Death Metal", _
	"Pranks", "Soundtrack", "Euro -Techno", "Ambient", _
	"Trip -Hop", "Vocal", "Jazz Funk", "Fusion", _
	"Trance", "Classical", "Instrumental")

iLower = LBound(GenresTypes)
iUpper = UBound(GenresTypes)
For x = iLower To iUpper
	Combo1.AddItem GenresTypes(x)
Next x
End Sub
Tip:

When you use a For...Next loop to iterate through an array, you may be inclined to hard code the starting and ending counter values. For instance, in the loop in Listing F, we could have used

For x = 0 to 33
However, because you may want to expand the genre list at a later time, it's best to use the LBound() and UBound() functions to delimit the counter's boundaries. That way, no matter how many times you add items to the array, you won't need to modify the For...Next loop at all. Also, keep in mind that we didn't need to subtract 1 from the UBound() value because the function returns the array's largest available subscript not the number of items in the array.

At this point, we have a fully functional MP3 player. In this article, we've shown you how not only to take advantage of Windows Media Player to play MP3s, but how to decode the ID3 tag information as well. You're ready to take full advantage of this exciting format. Now you better get out there and find some decent MP3s before they're gone!

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only 3 numbers of interest to a computer scientist: 1, 0 and infinity”