Features
      Ask DevGuru
      ASP Resources
      Find the Bug
      Knowledge Base
      Links
      Tips of the Week
      Tutorials
  Products
      dgCalendar
      dgCharge New!
      dgChart New!
      dgFileUpload
      dgReport New!
      dgSort
      dgTree
  Site
      Authoring
      Coming Soon
      DevGuru Resume
      Link to Us
      Merchandise
      Sponsorships
      Testimonials
      What's New
  Technologies
      ADO 2.6
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      Transact-SQL Syntax
      VBScript
      WML
      WMLScript
      WSH
      XML DOM

              











FUNCTION:  Rnd( )

Rnd(Number)
 
The Rnd function generates a pseudo-random number greater than or equal to 0.0 and less than 1.0.
 
The Number argument is optional, but different numbers will give different pseudo-random numbers.
 
Note that the number generated is pseudo-random, because the same output tends to be repeated over and over. You can use the Randomize statement to over come this problem.
 
Code:
<% =Rnd() %>
 
Output:
0.7055475
 
Code:
<% =Rnd(127.89) %>
 
Output:
0.533424
 
Code:
<% =Rnd(-127.89) %>
 
Output:
0.6953956
 
Code:
<% Randomize %>
<% =Rnd() %>

 
Output:
0.1414095
 
The following code will generate a random number between any limits you choose. (Since the Int function always rounds down, we add one to the difference between the limits.)
 
Code:
<% upperlimit = 50000.0 %>
<% lowerlimit = -30000.0 %>
<% =Int((upperlimit - lowerlimit + 1)*Rnd() + lowerlimit) %>

 
Output:
30366


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information