I have the following VB code. I'm trying to get it to randomize a quote to be printed to the page on refresh, but it's not doing it for me.
Is there something obviously wrong?
Dim quotes As New ArrayList, quoters As New ArrayList
quotes.Add("The Warehouse excites me every single time"): quoters.Add("- Samantha Jones")
quotes.Add("Everyone is just so friendly"): quoters.Add("- Bianca Emit")
quotes.Add("A great place to explore new things!"): quoters.Add("- Adrian Soft")
quotes.Add("I absolutely LOVE The Warehouse!!!!!!!!!!!!!"): quoters.Add("- Adam Jenkins")
quotes.Add("I look forward to it every week!"): quoters.Add("- Mary Binge")
Dim quoteNumber As Byte = CInt * (quotes.Count - 1)
Response.Write("""" & quotes(quoteNumber) & """<br />" & vbCrLf)
Randomize just initialises the random number generator. You need to call
Rnd() to generate a random number between 0 and 1. Then multiply by the range you need. ie
count - 1
Dim quoteNumber as Integer = CInt( Rnd() * (quotes.Count - 1) )