Home | Advertising Info2 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Monday, May 13, 2024  

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Code Samples
 PowerASP Code Help Area : Classic ASP - Code Samples
Subject Topic: Basic ASP Randomizer Example Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
cwilliams
Admin Group
Admin Group
Avatar

Joined: April/26/2004
Location: United States
Online Status: Offline
Posts: 137
Posted: 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 posts by cwilliams
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

   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 a directory of ASP tutorials applications scripts components and articles for the novice to professional developer. CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com