title: Get a Random Item from an Array
body: <p>I am starting with this basic code sample:</p>
  
  <pre><code>&lt;%
  block1 = "tree, ball, cheese, rabbit, waffle, planet, string, cat, dog, hole, hobbit, sing,"
  
  wordArray1 = split(block1, ",")
  
  For Each item In wordArray1
      Response.Write(item &amp; "&lt;br /&gt;")
  Next
  
  max=11
  min = 1
  Randomize
  rand1 = Int((max-min+1)*Rnd+min)
  
  response.write "&lt;hr/&gt;rand1: " &amp; rand1 &amp; "&lt;hr/&gt;"
  
  w1 = wordArray1(0,rand1)
  
  response.write "w1: " &amp; w1 &amp; "&lt;hr/&gt;"
  %&gt;
  </code></pre>
  
  <p>I start with a list of words split by commas (block1).</p>
  
  <p>I convert that into an array (wordArray1)</p>
  
  <p>I can prove that array exists by looping through it and printing the array values to the page.</p>
  
  <p>I then would like to be able to randomly select just 1 value from that array.</p>
  
  <p>I thought I could just do something like:</p>
  
  <pre><code>max=11
  min = 1
  Randomize
  rand1 = Int((max-min+1)*Rnd+min)
  
  response.write "&lt;hr/&gt;rand1: " &amp; rand1 &amp; "&lt;hr/&gt;"
  
  w1 = wordArray1(0,rand1)
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre><code>Microsoft VBScript runtime error '800a0009'
  Subscript out of range: 'wordArray1'
  </code></pre>
  
  <p>How can I randomly access one of the array?</p>
  
  <p>Thanks</p>