Home | Advertising Info12 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Thursday, April 18, 2024  

  Active InfoActive Info  Display List of Info MembersMemberlist  Search The InfoSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Code Samples
 PowerASP Code Help Area : Classic ASP - Code Samples
Subject Info: Basic ASP Randomizer Example A d d  -  P o s tAdd P o s t
Author
Message << Prev Info | Next Info >>
cwilliams
Admin Group
Admin Group
Avatar

Joined: April/26/2004
Location: United States
Online Status: Offline
Info: 137
Added: April/27/2004 at 8:12pm | IP Logged Quote cwilliams

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.

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.

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 %>
"BANNER_ADS/ITSHUGE.gif"
<% Case 2 %>
"BANNER_ADS/STACKED_DEEP.gif"
<% Case 3 %>
"BANNER_ADS/ITSHUGE.gif"
<% Case 4 %>
"BANNER_ADS/STACKED_DEEP.gif"
<% Case 5 %>
"BANNER_ADS/ITSHUGE.gif"
<% Case 6 %>
"BANNER_ADS/STACKED_DEEP.gif"
<% Case 7 %>
"BANNER_ADS/ITSHUGE.gif"
<% Case 8 %>
"BANNER_ADS/STACKED_DEEP.gif"
<% Case 9 %>
"BANNER_ADS/ITSHUGE.gif"
<% Case 10 %>
"BANNER_ADS/STACKED_DEEP.gif"
<% End Select %>



__________________


Chris Williams
http://www.PowerASP.com
Back to Top View cwilliams's Profile Search for other info by cwilliams
 

If you wish to make a comment to this info you must first login
If you are not already registered you must first register

  A d d  -  P o s tAdd P o s t
Printable version Printable version

Info Jump
You cannot add new info in this area
You cannot add to info in this area
You cannot delete your info in this area
You cannot edit your info in this area
You cannot create polls in this area
You cannot vote in polls in this area

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2024 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages ASP control controls class classes module script Scripts applet CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com