|
|
|
|
|
| | |
Basic ASP Randomizer Example
Usage:
Randomize(Cbyte(Left(Right(Time(),5),2)))
RANDOMVALUE = Int((Highnumber - Lownumber + 1) * Rnd +
Lownumber)
The extra code added to the Randomize function
ensures that you get as random a value as possible. Without it certain
numbers will show up more often than others as computers are not very good
at generating random values.
You don't have to use case statements, but in this example I did. There are many things
you can do with the resulting value. This is just an example of using this code to
generate a simple random banner rotator. You also can use response.writes to
eliminate a lot of the script tags but I wanted to keep this example simple
for the newbie's. It is easier to understand this way.
This code will basically give you a random Integer from a range of 1 to 10 that you do
whatever you want with like make a random banner rotator. Remember you can change the
highnumber and lownumber to generate a random number within a greater range. See Usage at top of this page.
<%
Randomize(Cbyte(Left(Right(Time(),5),2)))
RANDOMVALUE =(Int((10 - 1 + 1) * Rnd + 1))
Select Case RANDOMVALUE
%>
<% Case 1 %>
<img src="BANNER_ADS/ITSHUGE.gif">
<% Case 2 %>
<img src="BANNER_ADS/STACKED_DEEP.gif">
<% Case 3 %>
<img src="BANNER_ADS/ITSHUGE.gif">
<% Case 4 %>
<img src="BANNER_ADS/STACKED_DEEP.gif">
<% Case 5 %>
<img src="BANNER_ADS/ITSHUGE.gif">
<% Case 6 %>
<img src="BANNER_ADS/STACKED_DEEP.gif">
<% Case 7 %>
<img src="BANNER_ADS/ITSHUGE.gif">
<% Case 8 %>
<img src="BANNER_ADS/STACKED_DEEP.gif">
<% Case 9 %>
<img src="BANNER_ADS/ITSHUGE.gif">
<% Case 10 %>
<img src="BANNER_ADS/STACKED_DEEP.gif">
<% End Select %>
|
|
|
|
|
|
|
|
|
|