Código fuente de 'Citas-ordenadas-al-azar.asp'

<html>
<head>
<title>Citas ordenadas al azar - Códigos asp, programacion asp, descargas asp, rutinas asp</title>
</head>
<body style="font-family: Arial; font-size: 11pt">

<p align="center"><b><font size="3">Citas ordenadas al azar</font></b></p>
  <p>Pulsa refrescar la pantalla, para ordenar las citas aleatoriamente.</p><br>
<%

  'Lets say you have a list of quotes (like below) or any other list
       'and you would like to display them in a random order whenever anyone access your page.
  'The following code will take your list of qotes, descriptions, or whatever
       'and display them in a random order, dispaying them all without repeating any of them.
  'This code also demonsrates how to display an array in random order and different ways to use arrays.

   'This is the list of stuff
   Dim Quote(20)
   Quote(0) = "Music should strike fire from the heart of man, " & _
              "and bring tears from the eyes of woman. " & _
              "<em>~ Ludwig Van Beethoven</em>"
   Quote(1) = "&#34;Sucking all the marrow out of life&#34; " & _
              "doesn't mean choking on the bone. " & _
              "There's a time for daring and there is a time for caution, " & _
              "and a wise man understands which is called for. " & _
              "<em>~ John Keating - &#34;Dead Poets Society&#34;</em>"
   Quote(2) = "I'm not bad, I'm just drawn that way. " & _
              "<em>~ Jessica Rabbit - &#34;Who Framed Roger Rabbit&#34;</em>"
   Quote(3) = "No matter what anybody tells you, " & _
              "words and ideas can change the world. " & _
              "<em>~ John Keating - &#34;Dead Poets Society&#34;</em>"
   Quote(4) = "Narf!  Zort!  Poit!  Gat! " & _
              "<em>~ Pinky - &#34;Pinky and the Brain&#34;</em>"
   Quote(5) = "Am I the only one that makes cofee around here?! " & _
              "<em>~ Brain - &#34;Pinky and the Brain&#34;</em>"
   Quote(6) = "I don't know the key to success, " &_
              "but the key to failure is trying to please everybody." & _
              "<em>~ Bill Cosby</em>"
   Quote(7) = "The key here, I think, is to not think of death as an end. " & _
              "But, but, think of it more as a very effective way of cutting down on your expenses. " & _
              "<em>~ Boris Grushenko - &#34;Love and Death&#34;</em>"
   Quote(8) = "Gentlemen. You can't fight in here. " & _
              "This is the War Room! " & _
              "<em>~ President Merkin Muffley - &#34;Dr. Strangelove&#34;</em>"
   Quote(9) = "Smile, it enhances your face value. " & _
              "<em>~ Truvy - &#34;Steel Magnolias&#34;</em>"
   Quote(10) = "Truth is like a blanket that always leaves your feet cold. " & _
               "You push it, stretch it, it'll never be enough. " & _
               "Kick at it, beat it, it'll never cover any of us. " & _
               "From the moment we enter crying, to the moment we leave dying, " & _
               "it'll just cover your face as you wail and cry and scream. " & _
               "<em>~ Todd - &#34;Dead Poets Society&#34;</em>"
   Quote(11) = "Champions aren't made in the gyms. " & _
               "Champions are made from something they have deep inside them " & _
               "-- a desire, a dream, a vision " & _
               "<em>~ Muhammad Ali</em>"
   Quote(12) = "Patriotism is not short, frenzied outbursts of emotion, " & _
               "but the tranquil and steady dedication of a lifetime. " & _
               "<em>~ Adlai Stevenson</em>"
   Quote(13) = "Who is General Failure and why is he reading my hard disk? " & _
               "<em>~ Steven Wright</em>"
   Quote(14) = "All I really need is love, " & _
               "but a little chocolate now and then doesn't hurt! " & _
               "<em>~ Lucy - &#34;Peanuts&#34;</em>"
   Quote(15) = "Someone sent me a postcard picture of the earth. " & _
               "On the back it said, &#34;Wish you were here.&#34; " & _
               "<em>~ Steven Wright</em>"
   Quote(16) = "If a word in the dictionary were misspelled, " & _
               "how would we know? " & _
               "<em>~ Steven Wright</em>"
   Quote(17) = "A friend is someone with whom you dare to be yourself. " & _
               "<em>~ Frank Crane </em>"
   Quote(18) = "Imagination is more important than knowledge. " & _
               "<em>~ Albert Einstein </em>"
   Quote(19) = "When you come to a fork in the road, take it. " & _
               "<em>~ Yogi Bera</em>"


  'Quote list is the variable that will hold the quotes
  QuoteList = ""
  'NumList is the variable that will hold the random numbers
     'we will use it to avoid duplicates. 
     'All the numbers in the list will begin with and end with a |
     'so we can keep them separated.
  NumList = "|"
  'Tour on Randomization
  Randomize
  'We have 20 quotes listed abouve, so we will will rin the script 20 times
  For x = 0 to 19
      'get random number
      RndQuote = Int(Rnd * 20)

      'If the random number in our list is already there,
         'we will keep picking numbers until 
         'we get one that is unique
      Do Until Instr(Cstr(NumList),Cstr("|" & RndQuote & "|")) = 0
         RndQuote = Int(Rnd * 20)
      Loop
       
      'Complile list of numbers
      NumList = NumList & RndQuote & "|"

      'Compile list of quotes
      QuoteList = QuoteList & Quote(RndQuote) & "|"
  Next

  'Trim last | from our quote list
  QuoteList = Left(QuoteList,Len(QuoteList)-1)

  'Create an array and display our list of quotes.
  QuoteArr = Split(QuoteList,"|")   
  For x = 0 to UBound(QuoteArr)

    Response.Write "<div style='color#000080;padding-top:10px;'>" & _
                   "<span style='color:#600000;font-weight:bold;'>&#149;</span> " & _
                    QuoteArr(x) & _
                   "</div>"

  Next

  %>
  

  
  </body></html>