Results 1 to 9 of 9

Thread: Array # and combobox problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    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:
    1. Private Sub Form_Load()
    2. Dim i
    3. Matrix = Array("Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", _
    4.             "Hip -Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&b", "Rap", "Reggae", _
    5.             "Rock", "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", _
    6.             "Soundtrack", "Euro -Techno", "Ambient", "Trip -Hop", "Vocal", "Jazz Funk", "Fusion", _
    7.             "Trance", "Classical", "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", _
    8.             "Noise", "AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", _
    9.             "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno -Industrial", "Electronic", _
    10.             "Pop -Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", _
    11.             "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret", "New Wave", _
    12.             "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo -Fi", "Tribal", "Acid Punk", "Acid Jazz", _
    13.             "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", _
    14.             "Swing", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", _
    15.             "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", _
    16.             "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata", _
    17.             "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore")
    18.  
    19. For i = 0 To UBound(Matrix)
    20.         combogenrefield.AddItem Matrix(i)
    21. Next i
    22. End Sub
    VB Code:
    1. ........
    2. temp = RTrim(.Genre)         'read genre character to "temp"
    3.         txtCombo.Text = Asc(temp)          'convert chr-code to ASCII-number
    4.         comboGenrefield.ListIndex = txtCombo.Text - 1

    From what I've seen, the number is correct, but the Name of the genre is not.

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    What's .Genre?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    .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

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Sorry, but... are you speaking English or am I that sleepy?

    Edit: forgot the -no offense intended-
    Last edited by Mc Brain; Jul 7th, 2002 at 06:34 PM.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    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
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  6. #6
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    VB Code:
    1. Dim Matrix() As Variant
    2.  
    3. Private Sub Form_Load()
    4.     Me.Show
    5.     Matrix() = Array("Adam", "Diana", "Bronwyn", "Charles")
    6.     For Counter = 0 To UBound(Matrix)
    7.         With Combo1
    8.             .AddItem Matrix(Counter)
    9.             .ItemData(.NewIndex) = Counter
    10.         End With
    11.     Next
    12.    
    13. End Sub
    14.  
    15. Private Sub Combo1_Click()
    16.     With Combo1
    17.         Debug.Print Matrix(.ItemData(.ListIndex)), .ItemData(.ListIndex), .ListIndex
    18.     End With
    19. End Sub

    Is this what u want?
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    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.

  8. #8
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    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.
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    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
  •  



Click Here to Expand Forum to Full Width