|
-
Jul 16th, 2002, 07:37 PM
#1
Thread Starter
Fanatic Member
Unresolved Array question
Ok, here it is broken down. I have this array in my form load event.
VB Code:
myarray= array("Jim", "Bob", "Sam", "Mike")
I use a function to read a integer value from a file that corresponds with that index in my array. However, somehow it gets off occasionally.
Say my function returns 2
since the first value in an array is 0 then Sam would be an index of 2
But sometimes when I use:
instead of returning Sam it returns Mike
However, Mike has an index of 3
What's going on here?
Also, I am using a For ....Next Loop to loop through a listview getting info on the files and converting the numbers to names .
This is just an example, my array contains about 128 different names. Any help is appreciated.
-Jeremy
-
Jul 16th, 2002, 07:42 PM
#2
-
Jul 16th, 2002, 07:45 PM
#3
Thread Starter
Fanatic Member
That's just it
The function returns the correct # always.
-
Jul 16th, 2002, 07:48 PM
#4
-
Jul 16th, 2002, 08:32 PM
#5
Thread Starter
Fanatic Member
Ok Micro, have at it.....
Here's the code:
General Declarations:
VB Code:
Option Explicit
Public Matrix
On The Form_Load Event:
VB Code:
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", "Alt. Rock", "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")
Code When I Populate the Listview Control:
VB Code:
On Error Resume Next
For X = 0 To File1.ListCount - 1
fname = File1.Path & "\" & File1.List(X)
'Get the MP3 info
ReadID3Info fname 'Read Id3v1.1 information
CMp3info.filename = fname 'Get mp3info such as bitrate
Set i = ListView1.ListItems.Add(, , File1.List(X))
i.SubItems(1) = Trim(GetID3.Artist)
i.SubItems(2) = Trim(GetID3.Songname)
i.SubItems(3) = Trim(GetID3.Album)
strTrack = Trim(GetID3.Track)
If strTrack = 0 Or 32 Then
strTrack = "-"
End If
i.SubItems(4) = strTrack
'------------------------------------------------------------------------------
tmpGenre = (GetID3.Genre) ' <--- Relevant Code
i.SubItems(5) = Matrix(tmpGenre)
'------------------------------------------------------------------------------
i.SubItems(6) = Format(FileLen(fname) / 1000000, "#0.00")
i.SubItems(7) = CMp3info.Frequency
tmpbitrate = CMp3info.BitRate
i.SubItems(8) = Left$(tmpbitrate, Len(tmpbitrate) - 3)
strMins = Format(CMp3info.Duration \ 60, "#0")
strsecs = Format(CMp3info.Duration Mod 60, "0#")
strLength = strMins & ":" & strsecs
i.SubItems(9) = strLength
i.SubItems(10) = fname
frmBuild.prog1.Value = frmBuild.prog1.Value + 1
DoEvents
Next
Any help appreciated.
-
Jul 16th, 2002, 08:40 PM
#6
PowerPoster
I'm not sure why you're having a problem here, but I think you're doing things in a way that is going to be very difficult to maintain.
I suggest that you put the matrix items in a text file instead of hard-coding it. That will make your app much more flexible in the future. Read the file into an array when the app loads and go from there.
-
Jul 16th, 2002, 11:57 PM
#7
New Member
No offense but, cafeenman's right. Try other means of storing your data other than the array.
Anyway, regarding with this part...
VB Code:
'------------------------------------------------------------------------------
tmpGenre = (GetID3.Genre) ' <--- Relevant Code
i.SubItems(5) = Matrix(tmpGenre)
'------------------------------------------------------------------------------
have you checked on tmpGenre's output? Truth is, I also don't find any problems with the results.
Know first the value of tmpGenre and compare it with your Matrix if the tmpGenre's value corresponds with that of Matrix's
VB Code:
'------------------------------------------------------------------------------
tmpGenre = (GetID3.Genre) ' <--- Relevant Code
i.SubItems(5) = Matrix(tmpGenre)
Debug.Print "tmpGenre=" & tmpGenre & _
": Matrix=" & Matrix(tmpGenre)
'------------------------------------------------------------------------------
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
|