how do I display a random word from an array of six words

  1. Create random generator between zero to five
  2. Get output number from it.
  3. The return number will be array position of a word to display

Hi,

Use the following code to get random values

<%
Option Explicit
Dim Tip(6)
Tip(1)  = "tip 1"
Tip(2)  = "tip 2"
Tip(3)  = "tip 3"
Tip(4)  = "tip 4"
Tip(5)  = "tip 5"
Tip(6)  = "tip 6"

Function RandomNumber(intHighestNumber)
	Randomize
	RandomNumber = Int(intHighestNumber * Rnd) + 1
End Function

Dim randval
randval = Tip(RandomNumber(10))
%>

randval is the random value from the array

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.