|
-
Jul 7th, 2002, 04:22 PM
#1
Thread Starter
Fanatic Member
Array # and combobox problem
Maybe someone can help me out with this. I've successfully made an MP3 ID3v1.1 tag editor that will be used as part of one of my projects. I'm having one problem that needs to be resolved though. The user will choose a genre from a combobox. There is an array in the form load event that holds all of the genre names. When the tag is written, the genre name in the combobox is converted to the index # in the array for that genre. The problem is that I can't get it to work correctly in the conversion process. Here's my code below. Any help with this is extremely appreciated as this is the last bug I have to work out.
VB Code:
Private Sub Form_Load()
Dim i
Matrix = 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", "Acid", "House", "Game", "Sound Clip", "Gospel", _
"Noise", "AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", _
"Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno -Industrial", "Electronic", _
"Pop -Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", _
"Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret", "New Wave", _
"Psychadelic", "Rave", "Showtunes", "Trailer", "Lo -Fi", "Tribal", "Acid Punk", "Acid Jazz", _
"Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", _
"Swing", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", _
"Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", _
"Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata", _
"Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore")
For i = 0 To UBound(Matrix)
combogenrefield.AddItem Matrix(i)
Next i
End Sub
VB Code:
........
temp = RTrim(.Genre) 'read genre character to "temp"
txtCombo.Text = Asc(temp) 'convert chr-code to ASCII-number
comboGenrefield.ListIndex = txtCombo.Text - 1
From what I've seen, the number is correct, but the Name of the genre is not.
-
Jul 7th, 2002, 05:50 PM
#2
-
Jul 7th, 2002, 06:22 PM
#3
Thread Starter
Fanatic Member
.genre is....
That reads the genre field via the ID3v11.bas and stores it as string called temp. I just left out the other reading of id3 fields before that since it's unrelated. Converting the # to genre name is the problem. Also, in Winamp, the genre combobox is sorted. Can this be done without mismatching the #'s with the genre names? If you need to see this I can send over a sample project a little later. Thanks
-
Jul 7th, 2002, 06:24 PM
#4
Need-a-life Member
-
Jul 7th, 2002, 06:32 PM
#5
PowerPoster
Me = lost too 
Let me see if I have this straight...
You create an array with all the genres
You put the array into a combo box
The user clicks on that combo box
and then u want to return the position?
ok, if the combo is unsorted, the listindex will give the array posn. If the combo is sorted you should set the ItemData property as u are adding array elements to the combo box. The array posn is then given by the ItemData of the selected Listindex
-
Jul 7th, 2002, 06:42 PM
#6
PowerPoster
VB Code:
Dim Matrix() As Variant
Private Sub Form_Load()
Me.Show
Matrix() = Array("Adam", "Diana", "Bronwyn", "Charles")
For Counter = 0 To UBound(Matrix)
With Combo1
.AddItem Matrix(Counter)
.ItemData(.NewIndex) = Counter
End With
Next
End Sub
Private Sub Combo1_Click()
With Combo1
Debug.Print Matrix(.ItemData(.ListIndex)), .ItemData(.ListIndex), .ListIndex
End With
End Sub
Is this what u want?
-
Jul 8th, 2002, 12:46 AM
#7
Thread Starter
Fanatic Member
ok beachbum........
Your first post is exactly what I'm trying to do. The only part I don't understand is how I use a sorted combo. Do I assign the values in the array or what. How do I use the itemdata property is I guess what I'm asking. Thanks for the help.
-
Jul 8th, 2002, 04:33 AM
#8
PowerPoster
Hey Hip
If u try out the little example with a sorted combo box u should see how ItemData works... Set the Sorted property of a combo box to true (must be done in design time)
When you create your array, the items will not be in order so
Item 0 is Adam
Item 1 is Diana
Item 2 is Bronwyn
Item 3 is Charles
Now, when you load them into the combo box they are going to sort automatically and their positions do not reflect their array number
ComboPosn 0 is Adam (array posn is 0)
ComboPosn 1 is Bronwyn (array posn is 2)
ComboPosn 2 is Charles (array posn is 3)
ComboPosn 3 is Diana (array posn is 1)
So, what u do is to record the array position in the Itemdata property as you add each new item. You can see the code in the previous post but essentially u are doing this...
Add Adam to the combo box
Record the Array Posn as 0 for that item
Add Diana to the combo box
Record the Array Posn as 1 for that item
..etc.. the combo box will then sort all the items.
Each time u click on the combo box, the Listindex returns the combo position and then all u have to do is to read that item's itemdata property to get the array position... eg
Say you click on Charles. This is the 2nd item in the sorted combo box but its itemdata property is 3 so u know that it is the 3rd item in the array.
-
Jul 8th, 2002, 08:23 AM
#9
Thread Starter
Fanatic Member
thanks
I understand now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|