Help Making Media Player

Cabose

Active member
Joined
Oct 18, 2006
Messages
39
Programming Experience
Beginner
I was wanting to make a media player with a media library and an id3 tag editor for my semester project in my programming class and i dont have any idea of how to do it will someone please help me figure it out?
I use VB .net 2005

Thanks,
Much
 
Do you intend on using a library?

if you do intend on using a music library.
then if you take a look at the library demo above, you could add a size property to the structure and for mp3 files you can use the .size property from the mp3 tag reader, or for wma files get the file size from fileinfo.size
.It also has a numeric sort button (but in this case it does them by track).
 
Cool, want some album art auto downloader code

sweet as.
Im working on it now, what i have done is mainly for demo purposes.
it will be fully funtional and more when finished.
do you want some source code to automaticly download album art?
 
i just added it

i just added it to that program above, here it is again.

it needs some error catching and it only shows the first image found, but thats easy to change

and title text box actually displayes the artist(for album art finding) so you might want to add a textbox for artist, but the edit button changes the title..
 

Attachments

  • Library_Demo.zip
    250.8 KB · Views: 43
All sorts of confusion

.It also has a numeric sort button (but in this case it does them by track).

Hey Qwazimoto, could you do me a favor and explain how

VB.NET:
Private Sub btnSort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSort.Click
Dim notfinished, itemsMoved As Boolean
itemsMoved = False
notfinished = True
Dim totalmoved As Integer = 0
Dim lastTrack As Integer = ML(0).Track
Do While notfinished = True
Dim i As Integer
itemsMoved = False
For i = 1 To ML.Length - 1
If ML(i).Track < ML(i - 1).Track Then
Dim SmlSng As Song = ML(i)
Dim BigSng As Song = ML(i - 1)
ML(i) = (BigSng)
ML(i - 1) = SmlSng
itemsMoved = True
totalmoved += 1
End If
lastTrack = ML(i).Track
Next
i = totalmoved
If itemsMoved = False Then notfinished = False
Loop
lsvResults.Items.Clear()
Showlib()
SaveLib()
End Sub

Works? I'm not following it one bit... even when im stepping through. I guess i'm not grasping the concept. There are no comments showing how it works :confused:
 
Ok

Sorry for not commenting it, I was trying real hard to include comments with all of this code too.. at 3 in the morning the little things seem to slip my mind. there were a few pointless variables in there (not sure what i was thinking to be honest) but it should be easier to understand.

Here is the code with comments...

VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] btnSort_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] btnSort.Click[/SIZE]
 
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] itemsMoved [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Boolean[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'USed to continue the DO loop, set to false when no items [/COLOR][/SIZE][SIZE=2][COLOR=#008000]Have been 'moved, [/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'and there is an if statement after the for [/COLOR][/SIZE][SIZE=2][COLOR=#008000]loop that ends the do 'loop '(which [/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'means we are finished) when [/COLOR][/SIZE][SIZE=2][COLOR=#008000]this value is false after the for 'loop...[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#008000]'We dont need to start the for loop at 0 because there[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'is no previous items to compare it with, so we start at 1 and[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'from there on we compare it with "i-1" (the item before it)[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Do  [/COLOR][/SIZE][SIZE=2][COLOR=#008000]'The boolean "notfinished" that i used was not needed at all, [/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]     'this is more practicle ... [/COLOR][/SIZE][SIZE=2][COLOR=#008000]'this "Do" loop is terminated at the [/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]     'end with "Exit Do" if there were no items moved[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]   Dim[/COLOR][/SIZE][SIZE=2] i [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer  [/COLOR][/SIZE][SIZE=2][COLOR=#008000]'used to count our way through the array[/COLOR][/SIZE]
 
[SIZE=2]   itemsMoved = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'set to false, set to true in if statement if [/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]                             'something [/COLOR][/SIZE][SIZE=2][COLOR=#008000]was moved[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]   For[/COLOR][/SIZE][SIZE=2] i = 1 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] ML.Length - 1 [/SIZE][SIZE=2][COLOR=#008000]'loop through the entire array[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#008000]               'Compare the current Track with the previous track, if the current track is [/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]               'less than the last track, then ...[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]          If[/COLOR][/SIZE][SIZE=2] ML(i).Track < ML(i - 1).Track [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'(the previous songs track is higher 'than this one)[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#008000]                'SmlSng will be the current song [/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]                'BigSng will be the previous one [/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]                 Dim[/COLOR][/SIZE][SIZE=2] SmlSng [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Song = ML(i) [/SIZE][SIZE=2][COLOR=#008000]'Create another instance of a song for[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]                                   'this track (which is "smaller" than the previous track value)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]                 Dim[/COLOR][/SIZE][SIZE=2] BigSng [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Song = ML(i - 1) [/SIZE][SIZE=2][COLOR=#008000]'Create a new instance of a song for [/COLOR][/SIZE][SIZE=2][COLOR=#008000]this [/COLOR][/SIZE][SIZE=2][COLOR=#008000]track [/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]                                    '(which is "bigger" than[/COLOR][/SIZE][SIZE=2][COLOR=#008000] the current track value)[/COLOR][/SIZE]
 
[SIZE=2]                 ML(i) = (BigSng) [/SIZE][SIZE=2][COLOR=#008000]'Set the current song to the last one[/COLOR][/SIZE]
[SIZE=2]                 ML(i - 1) = SmlSng [/SIZE][SIZE=2][COLOR=#008000]'set the last song to the current one[/COLOR][/SIZE]
 
[SIZE=2]                 itemsMoved = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'Set to true so we know to do this loop again[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]          End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]    Next[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]  If[/COLOR][/SIZE][SIZE=2] itemsMoved = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Do  [/COLOR][/SIZE][SIZE=2][COLOR=#008000]'if no items were moved on the last for loop, then we are finished[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'Start the for loop again[/COLOR][/SIZE]
 
[SIZE=2]lsvResults.Items.Clear() [/SIZE][SIZE=2][COLOR=#008000]'clears the listview[/COLOR][/SIZE]
[SIZE=2]Showlib() [/SIZE][SIZE=2][COLOR=#008000]'Reshows the listview items[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'SaveLib() 'this saves the song array in its sorted state[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
Last edited:
Do you get ...

do you understand how i have used the song structure?
and how i used an array of this structure?
and how its sorting by the "Track" property of each song in this song array?
 
Yeah, my book explained well how to use a serialized database, and seeing your code into practical use made perfect sense. So I understand how to save the stuff to a .ser file, or any other kind of file format I want, but I'm looking over the sorting code right now. I have Fridays off and unfortunately, i left all my code at work. So, I have to re-download the project and check it all out again. No problem though.. the Hootches out here in Iraq have a 10KBps connection, which rocks... erm sucks!
 
Wow, it's amazing what you learn when there are comments in the code. I understand perfect now. Thanks for throwing the comments in there. Now... Here is an even better question for you. Say, you have multiple albums. There will be more than one "Track 1". So, Would you make another instance of the array, only with certain items... say you want to sort only the items that are "Checked". You could make a new array, fill it with the items that are checked, sort the items that way, and then display them again? or could you replace the items in the "Original" array with the new Sorted items? Here.. check out what I have so far. I am trying to make an explorer to browse the music, and be able to sort the music by filesize and tracknumber, and year. It's pretty cool so far except the sort is all screwed up. This will give you an idea on what i'm talking about and what I want to do.
 

Attachments

  • MP3 Organizer.zip
    517.9 KB · Views: 34
I found an issue with how you run your progress bar. I found that the way that I use is a little more efficient. When I used your method, I was getting percentages of 102, and 101, which would cause a nasty error. So, here is what I use, and I will always get a percentage of 100 at the end of the operation

First I dim my variable, and calculate the ProgressIteration. ProgressIteration is the number that I will multiply the counter by, in other words: ProgressIteration is how much the ProgressBar should increase each time Progress is reported.

VB.NET:
Dim Counter as Integer
Dim ProgressPercentage, ProgressIteration
ProgressIteration = 100 / fCount

Now I do the calculation, and instead of the ReportProgress method doing the calculations, I throw in an easy formula, similar to the one that you made, except that I dont use the CInt() function.

VB.NET:
Counter += 1
ProgressPercentage = ProgressIteration * Counter
BGW1.ReportProgress(ProgressPercentage)

I found that this works a little more efficient, when I was using yours, i was getting TargetInvocationErrors. I got that a lot in the last project that I did, and that was the solution I found. Seems like it works for this one also.
 
Sort Media

Here is some code for adding each song to its own album (which is a song array) and adding each album to its own artist (which is an album array) and last of all adding each artist to an artist array.
You could then sort any artists or albums songs by track or what ever.

first I prefer using a collection because of its .remove, so here is the code for converting a song array to a collection.
VB.NET:
[SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Convert_to_Col([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] songs() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Song)[/SIZE]
[SIZE=2] Temp_Col = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Collection[/SIZE]
[SIZE=2][COLOR=#0000ff] For[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] sng [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Song [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] songs    [/SIZE][SIZE=2][COLOR=#008000]'loop through songs [/COLOR][/SIZE]
[SIZE=2]      Temp_Col.Add(sng)               [/SIZE][SIZE=2][COLOR=#008000]'Add song to collection[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] Next[/COLOR][/SIZE]
[SIZE=2] Sort_Library(Temp_Col)              [/SIZE][SIZE=2][COLOR=#008000]'Call sort library passing it the new collection[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

and here is the code to add each track to its own album...

VB.NET:
[SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Sort_Library([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] Songs [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Collection)[/SIZE]
[SIZE=2][COLOR=#008000] 'This sub takes a collection of song's and adds each song to an array according to the album tag[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] Dim[/COLOR][/SIZE][SIZE=2] albCount [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] Dim[/COLOR][/SIZE][SIZE=2] Sort_Over [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Boolean[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Do [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Until[/COLOR][/SIZE][SIZE=2] Songs.Count = 1 [/SIZE][SIZE=2][COLOR=#008000]'Loop until all songs have been placed in appropriate albums[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]    Dim[/COLOR][/SIZE][SIZE=2] i, c [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]    ReDim[/COLOR][/SIZE][SIZE=2] temp_Songs(0) : temp_Songs(0) = Songs(1) [/SIZE][SIZE=2][COLOR=#008000]'Set to first item, (its set here to compare it)[/COLOR][/SIZE]
[SIZE=2]     i = 1 : c = 1 [/SIZE][SIZE=2][COLOR=#008000]'Set counters[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]     For [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] sng [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Song [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] Songs [/SIZE][SIZE=2][COLOR=#008000]'Loop through every song[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]          If[/COLOR][/SIZE][SIZE=2] Songs(i).Album = temp_Songs(0).album [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'if this songs album is the same, add it[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]              ReDim [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Preserve[/COLOR][/SIZE][SIZE=2] temp_Songs(c) [/SIZE][SIZE=2][COLOR=#008000]'increase the song array's length[/COLOR][/SIZE]
[SIZE=2]              temp_Songs(c) = Songs(i) : c += 1 [/SIZE][SIZE=2][COLOR=#008000]'Add the current song to the album & increment counter[/COLOR][/SIZE]
[SIZE=2]              Songs.Remove(i) [/SIZE][SIZE=2][COLOR=#008000]'Remove this song from the collection[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]         Else[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'No song was removed from collection [/COLOR][/SIZE]
[SIZE=2]              i += 1 [/SIZE][SIZE=2][COLOR=#008000]'This song is not in this album so increment file index[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]         End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]     Next[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]     ReDim [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Preserve[/COLOR][/SIZE][SIZE=2] Temp_Albums(albCount) [/SIZE][SIZE=2][COLOR=#008000]'increase the albums array length[/COLOR][/SIZE]
[SIZE=2]     Temp_Albums(albCount).Tracks = temp_Songs [/SIZE][SIZE=2][COLOR=#008000]'Set this collection of songs to an album[/COLOR][/SIZE]
[SIZE=2]     albCount += 1 [/SIZE][SIZE=2][COLOR=#008000]'Increase the album count [/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] Loop[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Now we should have an array of albums, each with atleast one track[/COLOR][/SIZE]
[SIZE=2] MsgBox(Temp_Albums.Length & [/SIZE][SIZE=2][COLOR=#800000]" : "[/COLOR][/SIZE][SIZE=2] & Temp_Albums(1).Tracks(0).Album)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
And now add each albm to its rightfull artist, and add artists to all artists
VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'======================================
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'Now give these albums to their artists
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'======================================
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'Create a collection from the album array
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] AlbCol [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Collection
[/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] lbm [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Album [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] Temp_Albums
     AlbCol.Add(lbm)
[/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'=======================================
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] allArtists() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Artist [/SIZE][SIZE=2][COLOR=#008000]'The main array of artists (all music)
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] artCount [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#008000]'Number of Artists
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Do Until [COLOR=#000000]albCol.Count = 1[/COLOR]
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]    Dim[/COLOR][/SIZE][SIZE=2] x [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]    Dim[/COLOR][/SIZE][SIZE=2] Temp_Artist [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Artist
[/SIZE][SIZE=2][COLOR=#0000ff]    Dim[/COLOR][/SIZE][SIZE=2] albumCount [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 1
[/SIZE][SIZE=2][COLOR=#0000ff]    ReDim[/COLOR][/SIZE][SIZE=2] Temp_Artist.Albums(0)
    Temp_Artist.Albums(0) = albCol(1)
    x = 1
[/SIZE][SIZE=2][COLOR=#0000ff]    For[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] alb [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Album [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] AlbCol [/SIZE][SIZE=2][COLOR=#008000]'Loop through albums
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]          If[/COLOR][/SIZE][SIZE=2] Temp_Artist.Albums(0).Tracks(0).Artist = alb.Tracks(0).Artist [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#008000]'Add to artist
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]                ReDim[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Preserve[/COLOR][/SIZE][SIZE=2] Temp_Artist.Albums(albumCount) [/SIZE][SIZE=2][COLOR=#008000]'Increment the Album array length
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]                [/COLOR]Temp_Artist.Albums(albumCount) = alb [/SIZE][SIZE=2][COLOR=#008000]'Set the new album to alb
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]                [/COLOR]albumCount += 1 [/SIZE][SIZE=2][COLOR=#008000]'Increment the Album count
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]                [/COLOR]AlbCol.Remove(x) [/SIZE][SIZE=2][COLOR=#008000]'Remove the added item
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]          Else
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]                [/COLOR]x += 1 [/SIZE][SIZE=2][COLOR=#008000]'No album was added to artist & one wasnt removed from
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]                          'collection so increment counter to next songs position
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]          End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]     Next
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]     ReDim[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Preserve[/COLOR][/SIZE][SIZE=2] allArtists(artCount)   [/SIZE][SIZE=2][COLOR=#008000]'Increment Artist array length
[/COLOR][/SIZE][SIZE=2]     allArtists(artCount) = Temp_Artist     [/SIZE][SIZE=2][COLOR=#008000]'Add artist to All artists
[/COLOR][/SIZE][SIZE=2]     artCount += 1                              [/SIZE][SIZE=2][COLOR=#008000]'Increment artist coung
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Loop
[/COLOR][/SIZE][SIZE=2]MsgBox(allArtists.Length & [/SIZE][SIZE=2][COLOR=#800000]": Artists in Total"[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE]
 
Last edited:
Back
Top