Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - ASP Random Number
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ASP Random Number

 Post Reply Post Reply
Author
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Topic: ASP Random Number
    Posted: 26 February 2005 at 12:56am
Using this code:

            Randomize

            'Get random number
            lngRandomNumber = int(rnd*118) + 1


Problem is, the results don't seem to be random.  The code is looped 9 times, and the 9 results seem to have a predictable pattern.

Is this normal?  Any better alternative?
Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Posted: 26 February 2005 at 1:30am
Originally posted by Gullanian Gullanian wrote:

Using this code:

            Randomize

            'Get random number
            lngRandomNumber = int(rnd*118) + 1


Problem is, the results don't seem to be random.  The code is looped 9 times, and the 9 results seem to have a predictable pattern.

Is this normal?  Any better alternative?
Personally, I think you should create a function to randomise the number for you ... then call as needed Big smile
 
Here's one for you to help you too Smile
 
<%
' Create a function to randomise a number
Function RandomNumber(intHighestNumber)
 Randomize
 RandomNumber = Int(intHighestNumber * Rnd) + 1
End Function
%>
 
Then call in the script
 
<%= RandomNumber("118") %>
 
Hope that helps dude.
 
Chris
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 26 February 2005 at 3:03am
it's th e exact same code, just in a function
Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2005 at 9:26pm
But this works !!!!
 
Give it a go, I promise you it works.
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2005 at 9:18am
this is not the exact same code or system. before

it was getting the random number and * 118  and +1

the above works as you set a different value for inthighestnumber.

this value can be anything, and so if you have a random number there it has a random output compared to the original.


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.