Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / minimum and maximum numbers

Author
Message
soadjason
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location:
Posted: 12th May 2005 13:23
Here is my code to give me a random dollar amount.


Eventually the number gets way too high or low. Does anyone have an idea that will keep the number to be between 1.50 and 3.00? I guess IF THEN may work, but I am not sure how to use this command. Any help would be appreciated.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th May 2005 18:14
a# = (RND(150) + 150) / 100.0

That should do it, all in one line.

BatVink
soadjason
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location:
Posted: 12th May 2005 22:42
Thank you BatVink. That certainly is a shorter way of doing it, but I need the number to increase/decrease by a small percentage. I probably should have pointed that out in my first post. The way you have done it the number may go from 1.5 to 3.0 in one cycle. I may be able to use this formula for something else, so again thank you. Any other suggestions?
Avan Madisen
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: The Castle Anthrax
Posted: 13th May 2005 07:59
try this in your loop



that should keep a# between 1.5 and 3, plus it'll change randomly by small, random amounts. Be aware that it'll be quite rare that it will get anywhere near 1.5 or 3.

I don't suffer from insanity - I enjoy every minute of it!
Current Projects: Lemmings Remake
(Untitled) Puzzle Game for the Compo
soadjason
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location:
Posted: 15th May 2005 00:32
Thanks Avan. I tried and it works perfect.

Login to post a reply

Server time is: 2024-09-23 19:27:24
Your offset time is: 2024-09-23 19:27:24