Print Page | Close Window

Randomize Problem

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10085
Printed Date: 31 March 2026 at 4:23pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Randomize Problem
Posted By: FLATLINE
Subject: Randomize Problem
Date Posted: 21 April 2004 at 12:47pm

I know that many questions regarding Randomization in asp were already posted, but my search didn't come up with the answer that I needed.

What I need is randomize a number between 0 and a certain variable which can also be fractional (eg 1.25), that randomized number is needed to be added or substracted from another variable (whether it'll be added or substracted is also randomized).



-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ



Replies:
Posted By: Mart
Date Posted: 21 April 2004 at 1:21pm
Function GenerateRandomNumber(Between1, Between2)
Randomize()
Dim intRandom
intRandom = INT(Rnd()*10)

While Not intRandom > Between1 Or Not intRandom < Between2
Randomize()
intRandom = INT(Rnd()*10)
End While

GenerateRandomNumber = intRandom
End Function

Then do <%= GenerateRandomNumber(0, 1.25) %?

Should work, no guarantees, just wrote it straight into here



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net