Results 1 to 7 of 7

Thread: randomize not working

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Posts
    131

    randomize not working

    Why is this not picking a random song for me? It worked like once, then kept playing the same song..

    VB Code:
    1. If mpMain.PlayState = mpStopped Then
    2.     UpperBound = Upper + 1
    3.     LowerBound = 0
    4.    
    5.     Upper = UBound(arrSongs)
    6.    
    7.     Randomize
    8.    
    9.     SongNum = Int((UpperBound - LowerBound + 1) * Rnd + LowerBound)
    10.     NAAAS.mpMain.Filename = arrSongs(SongNum)
    11.    
    12.     Text2.Text = arrSongs(SongNum)
    13. End If

  2. #2
    Addicted Member
    Join Date
    Jul 2001
    Location
    Minnesota, USA
    Posts
    134
    LowerBound never changes, it's always 0. Not sure if it'd change anything, but, something to point out.. you might as well just use hard code numbers, rather than variables for them.
    The answer is 42. Sadly, you can't typecast the "answer" data type to the "question" data type.

    Code:
    Take.Me( To( Your.Leader ) )

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Posts
    131
    I can't hardcode the numbers. Cause the array it uses is not always the same size..

  4. #4
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221
    try this

    VB Code:
    1. Randomize Timer
    2.    
    3.     SongNum = Int((CSng((UpperBound - LowerBound) + 1) * Rnd) + LowerBound)
    "1 4m 4 1337 #4xz0r!'
    Janus

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Posts
    131
    It still plays the same two songs.. Same as before also. So ther must be something else cause it to lean to thoes two songs.. But what is it?

  6. #6
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221
    That's because UpperBound is probably 1.
    Make it UBound(arrSongs) instead of Upper + 1.
    "1 4m 4 1337 #4xz0r!'
    Janus

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Posts
    131
    I got it working. I was just loading a small list and by chance getting the same songs.. I think. It seems to be working now. thanks..

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